-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Enable clicking of CF checkbox in CDP Async drivers using OpenCV-based template matching #3729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
It's already possible to click the CAPTCHA without UC Mode:
from seleniumbase import sb_cdp def main(): url = "www.planetminecraft.com/account/sign_in/" sb = sb_cdp.Chrome(url, lang="en") sb.sleep(2) sb.gui_click_element("#turnstile-widget div") sb.sleep(2) if __name__ == "__main__": main()
Also, your PR introduces a new dependency, opencv-python
, which is 150 times larger than seleniumbase
itself:
(Note that seleniumbase is still in kB, while opencv-python is in MB.)
That goes in the opposite direction from what most people want, which is a slimmer package (rather than a heavier one).
Also, image-based CAPTCHA-detection is not practical, nor efficient. The image could change, or it could appear different on different systems. If there were multiple windows open at the same time, that would also be a problem.
Rather than a PR, you could create a discussion in https://github.com/seleniumbase/SeleniumBase/discussions so that if anyone else is interested in image-based CAPTCHA detection and clicking, then they could find that information there.
This PR replaces the outdated verify_cf method, adding support for locating and clicking "cf" checkboxes in CDP Async drivers by leveraging OpenCV template matching. It is based on the implementation in the nodriver package, with the following enhancements:
Language-agnostic: works regardless of the driver lang (using a 36x36 px image of a cf checkbox cfbtn)
Per-tab UUIDs: each driver tab gets a unique UUID so that multiple drivers can operate in the same execution directory without clashing over temporary screenshots.
Temporary screenshot management: screenshots are saved to the working directory using the previously UUID and cleaned up after use.
New dependency: adds opencv-python for template matching functionality.