From b42582bab5b8aa20a4ded3d8a3e4473c901f69eb Mon Sep 17 00:00:00 2001 From: nemowang Date: Wed, 21 Jan 2026 17:38:30 +0800 Subject: [PATCH 1/2] [py] Fix return type hint for alert_is_present from 'bool' to 'Literal[False]' --- py/selenium/webdriver/support/expected_conditions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/selenium/webdriver/support/expected_conditions.py b/py/selenium/webdriver/support/expected_conditions.py index 4987631292d39..6ea5b9a495cd1 100644 --- a/py/selenium/webdriver/support/expected_conditions.py +++ b/py/selenium/webdriver/support/expected_conditions.py @@ -692,7 +692,7 @@ def _predicate(driver: WebDriver): return _predicate -def alert_is_present() -> Callable[[WebDriver], Alert | bool]: +def alert_is_present() -> Callable[[WebDriver], Alert | Literal[False]]: """Check that an alert is present and switch to it. Returns: From a0f8069391ccd6ab8085891bfa0dd4b4578c1342 Mon Sep 17 00:00:00 2001 From: Corey Goldberg <1113081+cgoldberg@users.noreply.github.com> Date: Thu, 22 Jan 2026 10:17:27 -0500 Subject: [PATCH 2/2] Fix docstring --- py/selenium/webdriver/support/expected_conditions.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/py/selenium/webdriver/support/expected_conditions.py b/py/selenium/webdriver/support/expected_conditions.py index 6ea5b9a495cd1..94931d1c062f4 100644 --- a/py/selenium/webdriver/support/expected_conditions.py +++ b/py/selenium/webdriver/support/expected_conditions.py @@ -696,15 +696,12 @@ def alert_is_present() -> Callable[[WebDriver], Alert | Literal[False]]: """Check that an alert is present and switch to it. Returns: - The Alert once it is located. + The Alert once it is located, or False if no alert is present. Example: from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC alert = WebDriverWait(driver, 10).until(EC.alert_is_present()) - - Note: - If the alert is present it switches the given driver to it. """ def _predicate(driver: WebDriver):