【问题标题】:How to click Hcaptcha checkbox with python selenium如何使用 python selenium 单击 Hcaptcha 复选框
【发布时间】:2021-10-19 15:45:59
【问题描述】:

我有 hcaptcha 复选框的 HTML 如下:

<div id="checkbox" aria-haspopup="true" aria-checked="false" role="checkbox" tabindex="0" aria-live="assertive" aria-labelledby="a11y-label" style="position: absolute; width: 28px; height: 28px; border-width: 1px; border-style: solid; border-color: rgb(145, 145, 145); border-radius: 4px; background-color: rgb(250, 250, 250); top: 0px; left: 0px;"></div>

我尝试了以下命令但没有成功:

check = driver.find_element_by_id("checkbox")
driver.execute_script("arguments[0].click();",check)

返回错误:

selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable

以下一些命令也不起作用:

driver.find_element_by_xpath('//*[@id="checkbox"]').click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div[1]/div[1]/div"))).click()

此链接:https://gleam.io/gIxR1/cyball-x-ancient8-20-common-packs-cyblocs-1000-usdt-social-giveaways

如何解决这个问题?

【问题讨论】:

  • 你能分享页面网址吗
  • 如何导航到该复选框?
  • 你需要连接到twitter并点击task follow twitter
  • 可能会检查 iframe,因为大多数验证码都加载了 iframe

标签: python selenium captcha


【解决方案1】:

可能是 iframe 中的验证码加载。所以首先你必须切换到 iframe 然后找到验证码

iframe = driver.find_element_by_xpath("IFRAME_XPATH_HERE")
driver.switch_to.frame(iframe)

现在您可以找到复选框

driver.find_element_by_xpath('//*[@id="checkbox"]').click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div/div[1]/div[1]/div"))).click()

【讨论】:

  • 我大约 1 天前修复了它,您的回答是正确的,我还必须切换到框架才能单击复选框。谢谢
猜你喜欢
  • 2018-10-31
  • 2019-10-10
  • 2022-01-07
  • 1970-01-01
  • 1970-01-01
  • 2017-09-24
  • 2021-12-11
  • 2021-12-23
  • 1970-01-01
相关资源
最近更新 更多