我有 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
如何解決這個問題?
uj5u.com熱心網友回復:
嘗試這樣做:
check = driver.find_element_by_xpath("/html/body/div/div[1]/div[1]/div")
check.click()
uj5u.com熱心網友回復:
可能是 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()
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/324936.html
