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() 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" diff --git a/seleniumbase/fixtures/js_utils.py b/seleniumbase/fixtures/js_utils.py index 7fabb26276a..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):