From d8b4447a3c00bab29d8b798a794d0bc01a25d8e8 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Thu, 12 Sep 2024 13:07:19 -0400 Subject: [PATCH 1/4] Fix an issue with UC Mode --- seleniumbase/core/browser_launcher.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/seleniumbase/core/browser_launcher.py b/seleniumbase/core/browser_launcher.py index d1d023e18af..73faacce734 100644 --- a/seleniumbase/core/browser_launcher.py +++ b/seleniumbase/core/browser_launcher.py @@ -989,7 +989,10 @@ def _uc_gui_click_captcha( reconnect_time = 1 # Make it quick (it already failed) driver.reconnect(reconnect_time) caught = False - if driver.is_element_present(".footer .clearfix .ray-id"): + if ( + driver.is_element_present(".footer .clearfix .ray-id") + and not driver.is_element_present("#challenge-success-text") + ): blind = True caught = True if blind: @@ -1209,7 +1212,10 @@ def _uc_gui_handle_captcha_(driver, frame="iframe", ctype=None): def _uc_gui_handle_captcha(driver, frame="iframe", ctype=None): _uc_gui_handle_captcha_(driver, frame=frame, ctype=ctype) - if driver.is_element_present(".footer .clearfix .ray-id"): + if ( + driver.is_element_present(".footer .clearfix .ray-id") + and not driver.is_element_present("#challenge-success-text") + ): driver.uc_open_with_reconnect(driver.current_url, 3.8) _uc_gui_handle_captcha_(driver, frame=frame, ctype=ctype) From 86f7fa0cbefb2a5b4e25d5bd0986a8ff5879f687 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Thu, 12 Sep 2024 13:09:03 -0400 Subject: [PATCH 2/4] Update AngularJS waiting settings --- examples/custom_settings.py | 2 +- seleniumbase/config/settings.py | 2 +- seleniumbase/fixtures/js_utils.py | 17 ++++++++--------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/examples/custom_settings.py b/examples/custom_settings.py index 15d137452d1..2eccc6bd8eb 100644 --- a/examples/custom_settings.py +++ b/examples/custom_settings.py @@ -48,7 +48,7 @@ # Called after self.click(selector), NOT element.click() WAIT_FOR_RSC_ON_CLICKS = False # Wait for AngularJS calls to complete after various browser actions. -WAIT_FOR_ANGULARJS = False +WAIT_FOR_ANGULARJS = True # Skip ALL calls to wait_for_ready_state_complete() and wait_for_angularjs(). SKIP_JS_WAITS = False diff --git a/seleniumbase/config/settings.py b/seleniumbase/config/settings.py index 1a9d88f04b3..0b2822100f3 100644 --- a/seleniumbase/config/settings.py +++ b/seleniumbase/config/settings.py @@ -75,7 +75,7 @@ # Called after self.click(selector), NOT element.click() WAIT_FOR_RSC_ON_CLICKS = False # Wait for AngularJS calls to complete after various browser actions. -WAIT_FOR_ANGULARJS = False +WAIT_FOR_ANGULARJS = True # Skip all calls to wait_for_ready_state_complete() and wait_for_angularjs(). SKIP_JS_WAITS = False diff --git a/seleniumbase/fixtures/js_utils.py b/seleniumbase/fixtures/js_utils.py index 7294063e0b7..de7420a8bd1 100644 --- a/seleniumbase/fixtures/js_utils.py +++ b/seleniumbase/fixtures/js_utils.py @@ -38,7 +38,7 @@ def wait_for_ready_state_complete(driver, timeout=settings.LARGE_TIMEOUT): time.sleep(0.03) return True if ready_state == "complete": - time.sleep(0.01) # Better be sure everything is done loading + time.sleep(0.002) return True else: now_ms = time.time() * 1000.0 @@ -61,15 +61,14 @@ def wait_for_angularjs(driver, timeout=settings.LARGE_TIMEOUT, **kwargs): driver.execute_script("") except Exception: pass - if hasattr(driver, "_is_using_uc") and driver._is_using_uc: - # Calling AngularJS waits may make UC Mode detectable. - # Instead, pause for a brief moment, and then return. - time.sleep(0.007) - return - if not settings.WAIT_FOR_ANGULARJS: + if ( + (hasattr(driver, "_is_using_uc") and driver._is_using_uc) + or not settings.WAIT_FOR_ANGULARJS + ): + wait_for_ready_state_complete(driver) return if timeout == settings.MINI_TIMEOUT: - timeout = settings.MINI_TIMEOUT / 4.0 + timeout = settings.MINI_TIMEOUT / 6.0 NG_WRAPPER = ( "%(prefix)s" "var $elm=document.querySelector(" @@ -96,7 +95,7 @@ def wait_for_angularjs(driver, timeout=settings.LARGE_TIMEOUT, **kwargs): try: execute_async_script(driver, script, timeout=timeout) except Exception: - time.sleep(0.0456) + pass def convert_to_css_selector(selector, by=By.CSS_SELECTOR): From e7f0d3407763f2c31b3a5804c2286941b0055745 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Thu, 12 Sep 2024 13:12:48 -0400 Subject: [PATCH 3/4] Refresh Python dependencies --- requirements.txt | 4 ++-- setup.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index 510ce34b74d..86b35e3b534 100755 --- a/requirements.txt +++ b/requirements.txt @@ -23,8 +23,8 @@ six==1.16.0 idna==3.8 chardet==5.2.0 charset-normalizer==3.3.2 -urllib3>=1.26.19,<2;python_version<"3.10" -urllib3>=1.26.19,<2.3.0;python_version>="3.10" +urllib3>=1.26.20,<2;python_version<"3.10" +urllib3>=1.26.20,<2.3.0;python_version>="3.10" requests==2.31.0 pynose==1.5.2 sniffio==1.3.1 diff --git a/setup.py b/setup.py index c84e5295244..6066e850fb1 100755 --- a/setup.py +++ b/setup.py @@ -171,8 +171,8 @@ "idna==3.8", 'chardet==5.2.0', 'charset-normalizer==3.3.2', - 'urllib3>=1.26.19,<2;python_version<"3.10"', - 'urllib3>=1.26.19,<2.3.0;python_version>="3.10"', + 'urllib3>=1.26.20,<2;python_version<"3.10"', + 'urllib3>=1.26.20,<2.3.0;python_version>="3.10"', 'requests==2.31.0', "pynose==1.5.2", 'sniffio==1.3.1', From 5ea2ee806dcbaf385270d2880aa3814af0c19979 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Thu, 12 Sep 2024 13:13:08 -0400 Subject: [PATCH 4/4] Version 4.30.6 --- seleniumbase/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seleniumbase/__version__.py b/seleniumbase/__version__.py index 468cc6ffc49..fad70e1fd37 100755 --- a/seleniumbase/__version__.py +++ b/seleniumbase/__version__.py @@ -1,2 +1,2 @@ # seleniumbase package -__version__ = "4.30.5" +__version__ = "4.30.6"