【发布时间】:2021-03-19 09:58:53
【问题描述】:
我想检查 Selenium Web 驱动程序对于以下 XPath 是否可见/存在/检测到元素:
//*[@data-animate-modal-popup="true"]
是否有任何 Selenium 的函数在该元素可见/存在/检测到时返回 TRUE 或 FALSE?
上次我使用以下 IF - Else
phone_number_invalid = driver.find_element_by_xpath('//*[@data-animate-modal-popup="true"]')
if phone_number_invalid:
code here .....
find_element_by_xpath 在找不到元素时总是抛出错误。我只想在元素可见/存在/检测到时获得 TRUE 或 FALSE。
谢谢。
【问题讨论】:
标签: python selenium selenium-webdriver