seleniumbase / SeleniumBase

📊 Python's all-in-one framework for web crawling, scraping, testing, and reporting. Supports pytest. UC Mode provides stealth. Includes many tools.
https://seleniumbase.io
MIT License
4.67k stars 929 forks source link

Add advanced UC Mode PyAutoGUI clicking methods #2910

Closed mdmintz closed 1 month ago

mdmintz commented 1 month ago

Add advanced UC Mode PyAutoGUI clicking methods

driver.uc_gui_click_x_y(x, y, timeframe=0.25)  # PyAutoGUI click screen

driver.uc_gui_click_cf(frame="iframe", retry=False, blind=False)  # (*)

👤 driver.uc_gui_click_x_y(x, y, timeframe=0.25) uses PyAutoGUI to click the screen at the coordinates. The mouse movement will take the duration of the timeframe.

👤 driver.uc_gui_click_cf(frame="iframe", retry=False, blind=False) has three args. (All optional). The first one, frame, lets you specify the iframe in case the CAPTCHA is not located in the first iframe on the page. The second one, retry, lets you retry the click after reloading the page if the first one didn't work (and a CAPTCHA is still present after the page reload). The third arg, blind, will retry after a page reload (if the first click failed) by clicking at the last known coordinates of the CAPTCHA checkbox without confirming first with Selenium that a CAPTCHA is still on the page.

mdmintz commented 1 month ago

This was resolved in 4.28.4 - https://github.com/seleniumbase/SeleniumBase/releases/tag/v4.28.4

mdmintz commented 1 month ago

In 4.28.5, lots of improvements were made: (https://github.com/seleniumbase/SeleniumBase/releases/tag/v4.28.5)

driver.uc_gui_click_captcha(frame="iframe", retry=False, blind=False)  # Detect and click CAPTCHA

driver.uc_gui_click_rc(frame="iframe", retry=False, blind=False)  # Click on Google reCAPTCHA

driver.uc_gui_click_cf(frame="iframe", retry=False, blind=False)  # Click on Cloudflare Turnstile

Note that Google reCAPTCHA is far more advanced than Cloudflare Turnstile. reCAPTCHA uses advanced AI to detect unusual behavior, and blocks on that (not just Selenium). We make no guarantees that your clicks on reCAPTCHA will succeed. (But if you have an issue with clicking a CF Turnstile, historically that has been very doable with automation.)