我正在尝试使用 selenium java 来自动化 Web 应用程序,这是我不断收到的消息 org.openqa.selenium.ElementClickInterceptedException: Element is not clickable at point (85,37)because another element obliged it in all the浏览器。
我尝试了所有的等待,显式等待 20 秒似乎有效,但通常也会失败。另外,这种情况发生在应用程序上的几乎每个元素之前,我认为在每个元素之前应用显式 wait 或 Thread.sleep 是一个很好的做法。
driver.findElement(By.xpath("//span[contains(text(),'Agent Corrections')]")).click();
WebDriverWait wait1 = new WebDriverWait(driver, 20);
wait1.until(ExpectedConditions.invisibilityOfElementLocated(By.id("preloader")));
String expectedText = "";
String actualText = driver.findElement(By.cssSelector("#users_management > div.panel-heading > h4")).getText();
Assert.assertEquals(expectedText, actualText);
driver.findElement(By.xpath("//span[contains(text(),'')]")).click();
driver.findElement(By.xpath("//span[contains(text(),'')]")).click();
wait1.until(ExpectedConditions.invisibilityOfElementLocated(By.id("preloader")));
driver.findElement(By.id("pcc")).sendKeys("");
driver.findElement(By.id("pnr")).sendKeys("");
driver.findElement(By.id("FFFormSubmit")).click();
wait1.until(ExpectedConditions.invisibilityOfElementLocated(By.id("preloader")));
元素模糊是通过 div id = preloader
最佳答案
我会首先检查预加载器是否显示,然后等待其不可见。这可能会使执行速度变慢,但它是安全的。
driver.manage().timeouts().implicitlyWait(5,TimeUnit.SECONDS) // this will make wait time of 5 seconds for each element including preloader.
WebDriverWait wait1 = new WebDriverWait(driver, 20);
if(driver.findElement(By.id("preloader")).isDisplayed())
{ wait1.until(ExpectedConditions.invisibilityOfElementLocated(By.id("preloader")));
}
关于java - 如何处理 <div id ="preloader"> 用 Selenium 模糊其他元素,检查其他答案没有任何帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57809310/