- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 8.6k
 
Description
What happened?
I tried to run my python selenium script today contains WebDriverWait class imported as follows and observed below Timeout exception. Please refer to Relevant log output section for error logs.
Example:
from selenium.webdriver.support.ui import WebDriverWait
element = WebDriverWait(browser, 10).until(
    EC.element_to_be_clickable((By.XPATH, '/html/body/div/div[2]/div/div[3]/div/form/input[2]'))
)
browser.execute_script('arguments[0].click();', element)
NOTE: The same python selenium script was working fine till last friday (4th Oct 2024) when I had SELENIUM 4.24.0 installed in mac system. Today i started seeing this issue, then when I investigated further, i observed that Selenium latest version 4.25.0 was installed in my system. Then I uninstalled SELENIUM 4.25.0 and reinstalled SELENIUM 4.24.0 in my system and found that my same python selenium scripts are started working fine now.
How can we reproduce the issue?
Just add WebDriverWait statement for any WebElement to be identified and run the .python script, you will observe Timeout exception.
Example: 
from selenium.webdriver.support.ui import WebDriverWait
    element = WebDriverWait(browser, 10).until(
        EC.element_to_be_clickable((By.XPATH, '/html/body/div/div[2]/div/div[3]/div/form/input[2]'))
    )
    browser.execute_script('arguments[0].click();', element)Relevant log output
I ran below CLI in pycharm IDE:
pytest generated_tests/test.py
Logs snippet:
fixturefunc = <function enter_service_into_username_field at 0x1054fe160>, request = <FixtureRequest for <Function test_login>>
kwargs = {'browser': <selenium.webdriver.chrome.webdriver.WebDriver (session="c588657992fd1ce9cec2495e13b6c354")>}
    def call_fixture_func(
        fixturefunc: _FixtureFunc[FixtureValue], request: FixtureRequest, kwargs
    ) -> FixtureValue:
        if is_generator(fixturefunc):
            fixturefunc = cast(
                Callable[..., Generator[FixtureValue, None, None]], fixturefunc
            )
            generator = fixturefunc(**kwargs)
            try:
                fixture_result = next(generator)
            except StopIteration:
                raise ValueError(f"{request.fixturename} did not yield a value") from None
            finalizer = functools.partial(_teardown_yield_fixture, fixturefunc, generator)
            request.addfinalizer(finalizer)
        else:
            fixturefunc = cast(Callable[..., FixtureValue], fixturefunc)
>           fixture_result = fixturefunc(**kwargs)
.venv/lib/python3.12/site-packages/_pytest/fixtures.py:898: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
generated_tests/login.py:35: in enter_service_into_username_field
    element = WebDriverWait(browser, 10).until(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <selenium.webdriver.support.wait.WebDriverWait (session="c588657992fd1ce9cec2495e13b6c354")>, method = <function visibility_of_element_located.<locals>._predicate at 0x105329e40>, message = ''
    def until(self, method: Callable[[D], Union[Literal[False], T]], message: str = "") -> T:
        """Calls the method provided with the driver as an argument until the \
        return value does not evaluate to ``False``.
    
        :param method: callable(WebDriver)
        :param message: optional message for :exc:`TimeoutException`
        :returns: the result of the last call to `method`
        :raises: :exc:`selenium.common.exceptions.TimeoutException` if timeout occurs
        """
        screen = None
        stacktrace = None
    
        end_time = time.monotonic() + self._timeout
        while True:
            try:
                value = method(self._driver)
                if value:
                    return value
            except self._ignored_exceptions as exc:
                screen = getattr(exc, "screen", None)
                stacktrace = getattr(exc, "stacktrace", None)
            time.sleep(self._poll)
            if time.monotonic() > end_time:
                break
>       raise TimeoutException(message, screen, stacktrace)
E       selenium.common.exceptions.TimeoutException: Message:
.venv/lib/python3.12/site-packages/selenium/webdriver/support/wait.py:105: TimeoutException
============================================================================================= short test summary info =============================================================================================
FAILED generated_tests/login.py::test_login - selenium.common.exceptions.TimeoutException: Message:
=============================================================================================== 1 failed in 14.44s ================================================================================================
(.venv) manikandanm ~/Test  $ pytest ./generated_tests/login.pyOperating System
Mac Ventura 13.5.1
Selenium version
Python 3.12
What are the browser(s) and version(s) where you see this issue?
Chrome, Version 129.0.6668.90
What are the browser driver(s) and version(s) where you see this issue?
Selenium 4.25.0
Are you using Selenium Grid?
No