【发布时间】:2020-01-08 13:58:09
【问题描述】:
我正在尝试使用 selenium java 自动化 Web 应用程序,这是我不断收到的消息 org.openqa.selenium.ElementClickInterceptedException: Element is not clickable at point (85,37) because another element obscured it in all the浏览器。
我尝试了所有的等待,显式等待 20 秒似乎有效,但通常也失败了。此外,这几乎发生在应用程序上的每个元素之前,我认为在每个元素之前应用显式等待或 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
【问题讨论】:
-
我们可以获取页面 URL 吗?
-
您还可以在使用单个元素之前检查它们是否可见/可点击/可交互。这将代替检查是否没有覆盖
-
不幸的是我不能给你页面 URL 因为它在组织之下。但是,当我在显式等待中使用其他任何东西而不是“元素的不可见性”时,它会失败。也可能是网络应用不稳定的问题。
-
20+ 秒等待每个元素听起来像是一个严重的问题。您要上传大文件吗?
-
不,没有文件。另外,我与一位开发人员交谈过,他说这个问题是因为他的代码是后端而我的脚本是前端而忽略了这个问题。搜索了很多,但找不到解决方案。