有没有一种方法可以检测是否存在使用Selenium阻止可点击元素的元素?

时间:2019-05-02 20:46:54

标签: javascript python selenium

我正在尝试创建一个脚本,该脚本将单击给定URL上的每个链接,但偶尔会出现弹出窗口/叠加层,从而阻止该链接。

是否可以使用Selenium或Javascript检测这些弹出窗口/叠加层?

我尝试使用is_displayedis_enabledEC.element_is_clickable,但似乎无济于事。

编辑:我希望找到一种无需单击即可检测阻塞元素的方法。

1 个答案:

答案 0 :(得分:0)

此使用此:

try:
    element.Click()
except ElementNotClickableException as x:
    //handle not being able to click element here, you can try to select the element by taking the attributes that are returned in the exception message, or check the exception message to see if it really is an ad, something like x.Message.Contains("class=pop-up")

希望有帮助

相关问题