Skip to content

Handle the special case of two (or more) CF CAPTCHAs on the same page at the same time #2956

@mdmintz

Description

@mdmintz

Handle the special case of two (or more) CF CAPTCHAs on the same page at the same time


This will probably never happen in a real-world situation, but it did happen on a test site (https://nopecha.com/captcha/turnstile), where two CF CAPTCHAs appeared on the same page at the same time.

Screenshot

UC Mode should have a way to click on both. Previously, (before CF moved CAPTCHAs into Shadow-DOM), UC Mode could select iframes directly, but now we need to select a parent element that isn't in Shadow-DOM. Something like this:

Screenshot

The existing (but still relatively new) uc_gui_click_captcha() methods could be modified to handle choosing between multiple CAPTCHAs (although as mentioned earlier, this is not likely to be seen in a real-world scenario, but it could be useful for testing).

Once complete, this script should work:

from seleniumbase import SB

with SB(uc=True, test=True) as sb:
    sb.uc_open_with_reconnect("nopecha.com/demo/turnstile", 3.2)
    sb.uc_gui_click_captcha("#example-container0")
    sb.uc_gui_click_captcha("#example-container5")
    sb.sleep(3)

That means that SeleniumBase/examples/raw_nopecha.py will need to be updated for the UC Mode changes.

If there's only one CAPTCHA on a page (which covers 99.99% of CAPTCHA pages), then sb.uc_gui_click_captcha() will still work as before. (No changes to that algorithm for the one-CAPTCHA scenario are expected.)

Metadata

Metadata

Assignees

Labels

UC Mode / CDP ModeUndetected Chromedriver Mode / CDP ModeenhancementMaking things bettertestsThis involves test updates or new tests

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions