Sun*_*ali 4 selenium webdriver selenium-webdriver
我们正在为 Web 应用程序做自动化,大多数情况下获取加载图标都会出现在页面中央.. 我们需要等待加载图标出现
<div id="loading" style="display: none; visibility: hidden;">
<div></div>
<div></div>
Run Code Online (Sandbox Code Playgroud)
示例:我们在大多数情况下都有搜索功能,我们正在获取此加载图标。
我们正在使用的 selenium webdriver:我们要完成加载的 id 是 id="loading".. 请任何人为我面临的上述问题提供解决方案。
我们有不同的功能,如点击和发送键
小智 5
显式等待应该有帮助:
public static String waitForElementNotVisible(int timeOutInSeconds, WebDriver driver, String elementXPath) {
if ((driver == null) || (elementXPath == null) || elementXPath.isEmpty()) {
return "Wrong usage of WaitforElementNotVisible()";
}
try {
(new WebDriverWait(driver, timeOutInSeconds)).until(ExpectedConditions.invisibilityOfElementLocated(By
.xpath(elementXPath)));
return null;
} catch (TimeoutException e) {
return "Build your own errormessage...";
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17992 次 |
| 最近记录: |