Selenium webdriver 如何通过Java使用SeleniumWebDriver等待所有加载程序消失
我正在使用SeleniumWeb驱动程序,需要等待所有加载程序消失。我在仪表板页面上有12个小部件,我需要等到所有小部件都加载完毕。加载程序显示在每个小部件上。我使用了以下两种方法,但都不起作用,也没有错误,它只是传递到下一个语句Selenium webdriver 如何通过Java使用SeleniumWebDriver等待所有加载程序消失,selenium-webdriver,xpath,css-selectors,loader,webdriverwait,Selenium Webdriver,Xpath,Css Selectors,Loader,Webdriverwait,我正在使用SeleniumWeb驱动程序,需要等待所有加载程序消失。我在仪表板页面上有12个小部件,我需要等到所有小部件都加载完毕。加载程序显示在每个小部件上。我使用了以下两种方法,但都不起作用,也没有错误,它只是传递到下一个语句 new WebDriverWait(driver,60) .until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//div[contains(text(),'Loader')]")));
new WebDriverWait(driver,60)
.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//div[contains(text(),'Loader')]")));
由于仪表板页面上总共有12个小部件,您需要等待,直到所有小部件都加载完毕,因此您必须为导入WebDriverWait,并且您可以使用以下任一方法:
- CSS选择器:
- xpath:
- CSS选择器:
- xpath:
WebDriverWait wait2 = new WebDriverWait(driver,60);
wait2.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector("div.loader")));
new WebDriverWait(driver, 20).until(ExpectedConditions.invisibilityOfAllElements(driver.findElements(By.cssSelector("div.loader"))));
new WebDriverWait(driver, 20).until(ExpectedConditions.invisibilityOfAllElements(driver.findElements(By.xpath("//div[@class='loader']"))));