判断元素是否可以点击
#判断元素是否可以点击
#利用显示等待
from
selenium
import
webdriver
from
selenium.webdriver.common.by
import
By
from
selenium.webdriver.support.ui
import
WebDriverWait
from
selenium.webdriver.support
import
expected_conditions as EC
driver
=
webdriver.Chrome()
driver.get(
"http://somedomain/url_that_delays_loading"
)
#判断元素是否可以点击
def
isclickable(xpath):
try
:
WebDriverWait(driver,
10
).until(
EC.element_to_be_clickable((By.XPATH, xpath)))
return
True
except
:
return
False