From e55bcc7a9f544cbb2ea9ad0c9d4fc358d36c055f Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Wed, 19 Aug 2026 11:50:43 -0400 Subject: [PATCH 1/4] Fix timeout issue with executing scripts in Selenium mode --- seleniumbase/fixtures/js_utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/seleniumbase/fixtures/js_utils.py b/seleniumbase/fixtures/js_utils.py index 7fabb26276a..e77bbc62264 100644 --- a/seleniumbase/fixtures/js_utils.py +++ b/seleniumbase/fixtures/js_utils.py @@ -103,6 +103,8 @@ def wait_for_angularjs(driver, timeout=settings.LARGE_TIMEOUT, **kwargs): } with suppress(Exception): execute_async_script(driver, script, timeout=timeout) + if hasattr(driver, "set_script_timeout"): + driver.set_script_timeout(30) # Restore default def convert_to_css_selector(selector, by=By.CSS_SELECTOR): From 37ace079c94bb9e08d4604387fbce13876ac00fb Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Wed, 19 Aug 2026 11:53:16 -0400 Subject: [PATCH 2/4] Update examples --- examples/cdp_mode/playwright/raw_walmart_sync.py | 7 +++---- examples/cdp_mode/raw_cdp_walmart.py | 6 ++---- examples/cdp_mode/raw_walmart.py | 6 ++---- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/examples/cdp_mode/playwright/raw_walmart_sync.py b/examples/cdp_mode/playwright/raw_walmart_sync.py index 7fb2840ed28..a3f4a1fb75e 100644 --- a/examples/cdp_mode/playwright/raw_walmart_sync.py +++ b/examples/cdp_mode/playwright/raw_walmart_sync.py @@ -40,11 +40,10 @@ and description.inner_text() not in unique_item ): unique_item.append(description.inner_text()) + print("* " + description.inner_text()) price = item.locator('[data-automation-id="product-price"]') if price.count() > 0: - print("* " + description.inner_text()) - price_text = price.inner_text() - price_text = price_text.split("current price Now ")[-1] + price_text = price.inner_text().strip() price_text = price_text.split("current price ")[-1] - price_text = price_text.split(" ")[0] + price_text = price_text.replace("\n", " ") print(" (" + price_text + ")") diff --git a/examples/cdp_mode/raw_cdp_walmart.py b/examples/cdp_mode/raw_cdp_walmart.py index 47d2ff1ce9c..30e4ac1a2ac 100644 --- a/examples/cdp_mode/raw_cdp_walmart.py +++ b/examples/cdp_mode/raw_cdp_walmart.py @@ -32,10 +32,8 @@ '[data-automation-id="product-price"]' ) if price: - price_text = price.text - price_text = price_text.split("current price Now ")[-1] + price_text = price.text.strip() price_text = price_text.split("current price ")[-1] - price_text = price_text.split(" ")[0] print(" (" + price_text + ")") - item.scroll_into_view() + item.scroll_into_view() sb.quit() diff --git a/examples/cdp_mode/raw_walmart.py b/examples/cdp_mode/raw_walmart.py index 1b47ea4fa2c..dd92c3a13dd 100644 --- a/examples/cdp_mode/raw_walmart.py +++ b/examples/cdp_mode/raw_walmart.py @@ -33,9 +33,7 @@ '[data-automation-id="product-price"]' ) if price: - price_text = price.text - price_text = price_text.split("current price Now ")[-1] + price_text = price.text.strip() price_text = price_text.split("current price ")[-1] - price_text = price_text.split(" ")[0] print(" (" + price_text + ")") - item.scroll_into_view() + item.scroll_into_view() From cd7b8945ca0298be0f7a8f6578ad4313107ed7c9 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Wed, 19 Aug 2026 11:53:37 -0400 Subject: [PATCH 3/4] Version 4.52.1 --- seleniumbase/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seleniumbase/__version__.py b/seleniumbase/__version__.py index 3d75d1477ff..ac42f1bb4bc 100755 --- a/seleniumbase/__version__.py +++ b/seleniumbase/__version__.py @@ -1,2 +1,2 @@ # seleniumbase package -__version__ = "4.52.0" +__version__ = "4.52.1" From a5e37fd41813e92ed60cb7554781d5ba3aae6ef4 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Wed, 19 Aug 2026 12:18:59 -0400 Subject: [PATCH 4/4] Improve the earlier commit that fixes the script timeout issue --- seleniumbase/fixtures/js_utils.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/seleniumbase/fixtures/js_utils.py b/seleniumbase/fixtures/js_utils.py index e77bbc62264..66724175376 100644 --- a/seleniumbase/fixtures/js_utils.py +++ b/seleniumbase/fixtures/js_utils.py @@ -56,12 +56,16 @@ def wait_for_ready_state_complete(driver, timeout=settings.LARGE_TIMEOUT): def execute_async_script(driver, script, timeout=settings.LARGE_TIMEOUT): - if hasattr(driver, "set_script_timeout"): - driver.set_script_timeout(timeout) - if hasattr(driver, "execute_async_script"): - return driver.execute_async_script(script) - else: - return None + try: + if hasattr(driver, "set_script_timeout"): + driver.set_script_timeout(timeout) + if hasattr(driver, "execute_async_script"): + return driver.execute_async_script(script) + else: + return None + finally: + if hasattr(driver, "set_script_timeout"): + driver.set_script_timeout(30) # Restore default def wait_for_angularjs(driver, timeout=settings.LARGE_TIMEOUT, **kwargs): @@ -103,8 +107,6 @@ def wait_for_angularjs(driver, timeout=settings.LARGE_TIMEOUT, **kwargs): } with suppress(Exception): execute_async_script(driver, script, timeout=timeout) - if hasattr(driver, "set_script_timeout"): - driver.set_script_timeout(30) # Restore default def convert_to_css_selector(selector, by=By.CSS_SELECTOR):