WebDriverWait(driver,20).until(EC.element_to_be_clickable((By.NAME, "username"))).send_keys("AHHHH")
WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe[name^='a-'][src^='https://www.google.com/recaptcha/api2/anchor?']")))
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//span[@id='recaptcha-anchor']"))).click()
WebDriverWait(driver,20).until(EC.element_to_be_clickable((By.NAME, "username"))).send_keys("AHHHH")
我的第一個((By.NAME, "username"))).send_keys("AHHHH")作業正常但是在我單擊頁面上的recaptcha 后,我突然收到錯誤:
File "/opt/homebrew/lib/python3.10/site-packages/selenium/webdriver/support/wait.py", line 90, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
我真的不太確定該怎么做,我已經嘗試了很多東西,包括從名稱切換到 xpath 以進行查找,我只是迷路了
uj5u.com熱心網友回復:
在 iframe 中完成操作后,如果您想與實際頁面中的元素進行互動,則需要退出它:
driver.switch_to.default_content()
硒檔案:https ://www.selenium.dev/documentation/
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/515486.html
標籤:Python硒
下一篇:表資料未回傳然后使用美湯
