小编the*_*Guy的帖子

Selenium + Java 的 elementToBeClickable 问题

所以,我有一个隐藏在警报下的元素。警报停留 10 秒,之后用户可以单击该元素。这是我处理这种情况的代码:

WebElement create = driver.findElement(By.cssSelector("div.action_menu_trigger"));
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.elementToBeClickable(create));
create.click();
Run Code Online (Sandbox Code Playgroud)

但是一旦 WebDriver 到达这里,我就会收到此异常,似乎 Selenium 并不关心等待方法:

org.openqa.selenium.ElementClickInterceptedException:
Element <div class="action_menu_trigger"> is not clickable at point (1710.224952697754,140) because another element <div class="noty_body"> obscures it
Build info: version: '3.13.0', revision: '2f0d292', time: '2018-06-25T15:24:21.231Z'
Run Code Online (Sandbox Code Playgroud)

我已经尝试过使用Thread.sleep(10000)并且效果很好,但我不想使用睡眠。

java selenium

3
推荐指数
1
解决办法
2622
查看次数

标签 统计

java ×1

selenium ×1