ajax – Selenium WebDriver – 确定元素是否可点击(即不被dojo模态灯箱遮盖)

前端之家收集整理的这篇文章主要介绍了ajax – Selenium WebDriver – 确定元素是否可点击(即不被dojo模态灯箱遮盖)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我编写自动脚本来测试在ajax上非常重的Web应用程序.例如,当保存设置时,将显示一个模态对话框,其中包含文本“保存…”,而灯箱会灰化页面的其余部分.

我的测试脚本尝试在消息消失之前单击测试中的下一个链接. Firefox几乎总是可以工作,但是当Chrome浏览器显示以下错误时:

Exception in thread "main" org.openqa.selenium.WebDriverException: Element is not clickable at point (99.5,118.5). Other element would receive the click: <div class="dijitDialogUnderlay _underlay" dojoattachpoint="node" id="lfn10Dijit_freedom_widget_common_environment_Dialog_8_underlay" style="width: 1034px; height: 1025px; "></div> (WARNING: The server did not provide any stacktrace information)

这是因为灯箱遮蔽了我想要点击的元素.尝试点击链接之前,我想等待灯箱消失.

检查灯箱不再存在是不是一个有效的解决方法,因为有时有多个级别的模态对话框和灯箱,并没有简单的方法来区分它们.

在Selenium中有没有办法检测元素是否可点击(没有其他元素模糊)?一个try / catch将是一个解决方法,但我宁愿做一个适当的检查,如果这是可能的.

使用WebDriverWait条件.
WebDriverWait wait = new WebDriverWait(yourWebDriver,5);
    wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//xpath_to_element")));

Webdriver将等待5秒钟,使您的元素能够被点击.

原文链接:https://www.f2er.com/ajax/160132.html

猜你在找的Ajax相关文章