等待硒中的ui数据过滤器
问题描述:
在应用程序中,很多字段都存在,并且所有字段都有过滤器(文本框)。所以一旦用户在任何一个过滤器中输入值,UI数据(UI表)将开始刷新。等待硒中的ui数据过滤器
我想等待数据在UI中加载,然后应用另一个过滤器。
有什么办法要等到数据被不使用的Thread.sleep
答
没有您提供进一步的细节加载,所有我可以推荐现在是FluentWait。例如:
final WebDriver driver = ...
new FluentWait<>(driver).withTimeout(30, SECONDS)
.pollingEvery(1, SECONDS)
.ignoring(NoSuchElementException.class)
.until(
webDvr -> !webDvr.findElements(By.xpath("//tr")).isEmpty()
);
+0
感谢您的回复....我有类似的情况在页面中我们有很多过滤器,默认情况下所有数据都显示.....现在我想申请过滤器一个接一个,然后再应用第二个(下一个)过滤器想要等待第一个(上一个)过滤器的数据过滤。另外,默认情况下“// tr”与一些数据一起存在。请帮我解决这个问题,因为我对硒世界很陌生。 –
答
我能执行此使用下面的代码 -
public boolean isElementDisplayed(WebElement element) {
try {
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.visibilityOf(element));
return element.isDisplayed();
} catch (Exception e) {
return false;
}
}
public void loadingTimer(){
WebElement element = driver.findElement(By.xpath("//span[contains(text(),'Loading...')]"));
if (isElementDisplayed(element)) {
WebDriverWait wait = new WebDriverWait(driver , 5);
wait.until(ExpectedConditions.not(ExpectedConditions.visibilityOf(element)));
}
}
见:我如何做X?(https://meta.*.com/questions/253069/whats-the-appropriate-new-current-close-reason-for-how-do-i-do-x)对SO的期望是用户提出问题不仅仅是研究回答他们自己的问题,研究,代码尝试和结果。这表明你已经花时间去尝试帮助自己,它使我们避免重申明显的答案,最重要的是它可以帮助你得到更具体和相关的答案!另请参见:[问] – JeffC