Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Selenium: How to let human interaction in a automated script?

I am working on a script that shows CAPTCHA and a few other stuff in a pop window. I am writing script for FireFox. Is it possible that I feed the values and on hitting Submit button script could resume the operations? I guess, some kind of infinite loop?

like image 241
Volatil3 Avatar asked Jan 21 '26 08:01

Volatil3


1 Answers

You could wait for the submit button to be clicked by the user:

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"
like image 172
Florent B. Avatar answered Jan 22 '26 23:01

Florent B.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!