我正在做一个使用selenium的脚本,在一个步骤中,它显示加载图标在webpage.The的中心加载图标出现后,第一行是执行
test.driver.findElement(By.id("oaapprove")).click();
test.driver.findElement(By.xpath("//*[text()='DATA EXPLORER']")).click();

第二个元素仍然在DOM中,但是它不能被点击,所以我得到了错误,因为它不能被点击
我试过这个:
Boolean isPresent=test.driver.findElements(By.xpath("//div[@class='spinner-container']")).size() > 0;
if(isPresent)
{
System.out.println("Target element found");
}
while(test.driver.findElements(By.xpath("//div[@class='spinner-container']")).size() > 0)
{
try {
System.out.println("inside");
Thread.sleep(250);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
if(!(test.driver.findElements(By.xpath("//div[@class='spinner-container']")).size() > 0))
{
System.out.println("Target element not found");
}它正在打印"inside“,直到加载图标可见,但在图标消失后,它不会打印"inside”,而是等待7-8秒,然后执行下一条语句。等待的原因是什么?
你能告诉我怎么解决这个问题吗?
发布于 2017-06-17 14:15:33
尝试actions类,如果它显示使用fluentwait,那么元素是可点击的:
WebElement yourElement = test.driver.findElement(By.xpath("//*[text()='DATA EXPLORER']"));
Actions act = new Actions(test.driver);
act.moveToElement(yourElement).click().build().perform();发布于 2017-06-18 20:27:17
我得到了解决方案并使用了stalenessOf
new WebDriverWait(driver, 10).until(ExpectedConditions.stalenessOf(findElement(By.xpath("element_path"))));https://stackoverflow.com/questions/44601043
复制相似问题