使用硒搜索html元素时出现“ NoSuchElementException”错误

时间:2020-05-18 12:05:10

标签: python selenium captcha

from selenium import webdriver

browser = webdriver.Chrome(r"C:\Users\PC\Desktop\selenium\chromedriver")
browser.get('https://www.google.com/recaptcha/api2/demo')

browser.find_element_by_id("recaptcha-anchor")

我试图找到并点击https://www.google.com/recaptcha/api2/demo中的验证码复选框

如果我没记错的话,它应该位于网站上的该范围之内

<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>

我尝试过按类和id搜索,但总是会出现错误。

0 个答案:

没有答案