Ram*_*aja 2 java selenium webdriver
我已经执行了一个动作WebDriver(比如说,我点击了一个按钮),结果是一个文本将显示在页面上.
我们不知道文本的定位元素,但我们知道会显示什么文本.
请建议一种等待文本显示的方法.
我遇到过WebDriverWait,但需要WebElement等待文字.
转到基于xpath文本的搜索.它允许您根据文本查找元素
// with * we are doing tag indepenedent search. If you know the tag, say it's a `div`, then //div[contains(text(),'Text To find')] can be done
By byXpath = By.xpath("//*[contains(text(),'Text To find')]");
WebElement myDynamicElement = (new WebDriverWait(driver, 10))
.until(ExpectedConditions.presenceOfElementLocated(byXpath));
Run Code Online (Sandbox Code Playgroud)