【问题标题】:No such element exception. Unable to locate element in selenium python没有这样的元素例外。无法在 selenium python 中找到元素
【发布时间】:2021-11-06 00:03:22
【问题描述】:
【问题讨论】:
标签:
python
selenium
web-scraping
data-mining
data-extraction
【解决方案1】:
由于即使在点击 I am not a Robot 之后我们也在自动化,它有时会再次重新验证码。能够使用以下代码单击复选框。
from selenium import webdriver
import time
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Chrome(executable_path="path to chromedriver.exe")
driver.maximize_window()
driver.implicitly_wait(30)
driver.get("https://www.archionweb.be/Public/Company/1930")
time.sleep(5)
iframe = driver.find_element_by_xpath("//iframe[@title='reCAPTCHA']")
driver.switch_to.frame(iframe)
time.sleep(5)
recaptcha = driver.find_element_by_class_name("recaptcha-checkbox-borderAnimation")
driver.execute_script("arguments[0].scrollIntoView(true);",recaptcha)
ActionChains(driver).move_to_element(recaptcha).click().perform()
time.sleep(2)
driver.switch_to.default_content()