Skip to main content
 首页 » 编程设计

python Selenium : How to let human interaction in a automated script

2025年04月02日20yjmyzz

我正在编写一个在弹出窗口中显示验证码和其他一些内容的脚本。我正在为 FireFox 编写脚本。是否有可能我提供这些值并点击提交按钮脚本可以恢复操作?我猜,某种无限循环?

请您参考如下方法:

您可以等待用户点击提交按钮:

from selenium import webdriver 
from selenium.webdriver.support.ui import WebDriverWait 
from selenium.webdriver.support import expected_conditions as EC 
 
# load the page 
driver.get("https://www.google.com/recaptcha/api2/demo") 
 
# get the submit button 
bt_submit = driver.find_element_by_css_selector("[type=submit]") 
 
# wait for the user to click the submit button (check every 1s with a 1000s timeout) 
WebDriverWait(driver, timeout=1000, poll_frequency=1) \ 
  .until(EC.staleness_of(bt_submit)) 
 
print "submitted"