Merge pull request #3129 from seleniumbase/uc-mode-reload-click

UC Mode: Reload & Click, as needed
This commit is contained in:
Michael Mintz 2024-09-12 14:52:17 -04:00 committed by GitHub
commit c3fbdb9302
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 10 deletions

View File

@ -1,2 +1,2 @@
# seleniumbase package # seleniumbase package
__version__ = "4.30.6" __version__ = "4.30.7"

View File

@ -900,6 +900,11 @@ def _uc_gui_click_captcha(
and driver.is_element_present("%s div" % frame) and driver.is_element_present("%s div" % frame)
): ):
frame = "%s div" % frame frame = "%s div" % frame
elif (
driver.is_element_present('[name*="cf-turnstile-"]')
and driver.is_element_present('[class*=spacer] + div div')
):
frame = '[class*=spacer] + div div'
elif ( elif (
driver.is_element_present('[name*="cf-turnstile-"]') driver.is_element_present('[name*="cf-turnstile-"]')
and driver.is_element_present("div.spacer div") and driver.is_element_present("div.spacer div")
@ -975,11 +980,14 @@ def _uc_gui_click_captcha(
driver.switch_to.default_content() driver.switch_to.default_content()
except Exception: except Exception:
return return
driver.disconnect()
try:
if x and y: if x and y:
sb_config._saved_cf_x_y = (x, y) sb_config._saved_cf_x_y = (x, y)
_uc_gui_click_x_y(driver, x, y, timeframe=0.95) if driver.is_element_present(".footer .clearfix .ray-id"):
driver.uc_open_with_disconnect(driver.current_url, 3.8)
else:
driver.disconnect()
try:
_uc_gui_click_x_y(driver, x, y, timeframe=0.54321)
except Exception: except Exception:
pass pass
reconnect_time = (float(constants.UC.RECONNECT_TIME) / 2.0) + 0.6 reconnect_time = (float(constants.UC.RECONNECT_TIME) / 2.0) + 0.6
@ -991,7 +999,7 @@ def _uc_gui_click_captcha(
caught = False caught = False
if ( if (
driver.is_element_present(".footer .clearfix .ray-id") driver.is_element_present(".footer .clearfix .ray-id")
and not driver.is_element_present("#challenge-success-text") and not driver.is_element_visible("#challenge-success-text")
): ):
blind = True blind = True
caught = True caught = True
@ -1214,7 +1222,7 @@ def _uc_gui_handle_captcha(driver, frame="iframe", ctype=None):
_uc_gui_handle_captcha_(driver, frame=frame, ctype=ctype) _uc_gui_handle_captcha_(driver, frame=frame, ctype=ctype)
if ( if (
driver.is_element_present(".footer .clearfix .ray-id") driver.is_element_present(".footer .clearfix .ray-id")
and not driver.is_element_present("#challenge-success-text") and not driver.is_element_visible("#challenge-success-text")
): ):
driver.uc_open_with_reconnect(driver.current_url, 3.8) driver.uc_open_with_reconnect(driver.current_url, 3.8)
_uc_gui_handle_captcha_(driver, frame=frame, ctype=ctype) _uc_gui_handle_captcha_(driver, frame=frame, ctype=ctype)