无法单击硒中的元素

邪恶医生

我正在尝试单击包含此网站上电话号码的元素,请在下面链接。它是说“ Toon Nummer”

元素位置

的元素。找到元素很容易:

tel = driver.find_element_by_xpath("//button[contains(@title, 'telefoon')]")


但是,如果我想单击它,到目前为止,我知道两种方法:

tel.click()

这只是返回ElementNotVisibleException。另一种方式:

driver.execute_script("arguments[0].click();", tel)

这只是不执行任何操作,没有错误,但是也没有单击,因为没有显示信息。我还可以做些什么才能成功单击它?
链接到网站

巡游

试试这个 :

phone_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, "//div[@id='vip-seller']/following-sibling::section/child::button")))  
phone_button .click()  

确保您正在导入这些:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC 

您编写的Xpath包含两个Web元素。希望这会有所帮助。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章