Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium webdriver 如何通过Java使用SeleniumWebDriver等待所有加载程序消失_Selenium Webdriver_Xpath_Css Selectors_Loader_Webdriverwait - Fatal编程技术网

Selenium webdriver 如何通过Java使用SeleniumWebDriver等待所有加载程序消失

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')]")));

我正在使用SeleniumWeb驱动程序,需要等待所有加载程序消失。我在仪表板页面上有12个小部件,我需要等到所有小部件都加载完毕。加载程序显示在每个小部件上。我使用了以下两种方法,但都不起作用,也没有错误,它只是传递到下一个语句

new WebDriverWait(driver,60)
.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//div[contains(text(),'Loader')]"))); 

由于仪表板页面上总共有12个小部件,您需要等待,直到所有小部件都加载完毕,因此您必须为导入WebDriverWait,并且您可以使用以下任一方法:

  • CSS选择器:

  • xpath:


由于仪表板页面上总共有12个小部件,您需要等待所有小部件加载完毕,因此您必须为导入WebDriverWait,并且您可以使用以下任一选项:

  • CSS选择器:

  • xpath:

invisibilityOfAllElements()在cssSelector上非常适合我。万分感谢:-)invisibilityOfAllElements()使用cssSelector对我来说非常适合。万分感谢:-)
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']"))));