【发布时间】:2020-05-30 18:57:58
【问题描述】:
我想点击 Google ReCAPTCHA 测试中的复选框。为此(我认为)我必须点击以下跨度:
<span class="recaptcha-checkbox goog-inline-block recaptcha-checkbox-unchecked rc-anchor-checkbox" role="checkbox" aria-checked="false" id="recaptcha-anchor" tabindex="0" dir="ltr" aria-labelledby="recaptcha-anchor-label"><div class="recaptcha-checkbox-border" role="presentation"></div><div class="recaptcha-checkbox-borderAnimation" role="presentation"></div><div class="recaptcha-checkbox-spinner" role="presentation"><div class="recaptcha-checkbox-spinner-overlay"></div></div><div class="recaptcha-checkbox-checkmark" role="presentation"></div></span>
https://patrickhlauke.github.io/recaptcha/ 网站在这里(它只是一个带有 ReCAPTCHA 的空网站)。
我正在使用最新版本的 Chrome 驱动程序,它被定义为驱动程序。我试过了:
driver.find_element_by_tag_name("span").click()
driver.find_element_by_xpath('//*[@id="recaptcha-anchor"]').click()
driver.find_element_by_id('recaptcha-anchor').click()
driver.find_element_by_class_name('recaptcha-checkbox goog-inline-block recaptcha-checkbox-unchecked rc-anchor-checkbox').click()
但我总是收到以下错误:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {*this is every try different*}
(Session info: chrome=83.0.4103.61)
我是 Python 的新手,这是我第一次尝试 Selenium。
【问题讨论】:
标签: python html selenium checkbox webdriver