Skip to content

TimeoutError on your example #339

@gregorleban

Description

@gregorleban

OS: Windows 11
Python: 3.11.5

I'm running the current selenium-driverless version and on the example code:

from selenium_driverless import webdriver
from selenium_driverless.types.by import By
import asyncio


async def main():
    options = webdriver.ChromeOptions()
    async with webdriver.Chrome(options=options) as driver:
        await driver.get('http://nowsecure.nl#relax', wait_load=True)
        await driver.sleep(0.5)
        await driver.wait_for_cdp("Page.domContentEventFired", timeout=15)
        
        # wait 10s for elem to exist
        elem = await driver.find_element(By.XPATH, '/html/body/div[2]/div/main/p[2]/a', timeout=10)
        await elem.click(move_to=True)

        alert = await driver.switch_to.alert
        print(alert.text)
        await alert.accept()

        print(await driver.title)


asyncio.run(main())

I get the exception:

Traceback (most recent call last):
  File "e:\Development\Anaconda3\Lib\asyncio\tasks.py", line 490, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
  File "e:\Development\Anaconda3\Lib\site-packages\cdp_socket\scripts\abstract.py", line 23, in __anext__
    return await self._fut
           ^^^^^^^^^^^^^^^
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "e:\Development\IJS\EventRegistry\python\ERApplyScripts\test.py", line 24, in <module>
    asyncio.run(main())
  File "e:\Development\Anaconda3\Lib\asyncio\runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "e:\Development\Anaconda3\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "e:\Development\Anaconda3\Lib\asyncio\base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "e:\Development\IJS\EventRegistry\python\ERApplyScripts\test.py", line 11, in main
    await driver.wait_for_cdp("Page.domContentEventFired", timeout=15)
  File "e:\Development\Anaconda3\Lib\site-packages\selenium_driverless\webdriver.py", line 1446, in wait_for_cdp
    return await self.current_target.wait_for_cdp(event=event, timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "e:\Development\Anaconda3\Lib\site-packages\selenium_driverless\types\target.py", line 1051, in wait_for_cdp
    return await self.socket.wait_for(event, timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "e:\Development\Anaconda3\Lib\site-packages\cdp_socket\socket.py", line 125, in wait_for
    raise e
  File "e:\Development\Anaconda3\Lib\site-packages\cdp_socket\socket.py", line 118, in wait_for
    res = await asyncio.wait_for(_iter.__anext__(), timeout)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "e:\Development\Anaconda3\Lib\asyncio\tasks.py", line 492, in wait_for
    raise exceptions.TimeoutError() from exc
TimeoutError

I also get the TimeoutError on all actions where I want to either find element or even call a .get() method to load another page. Any idea what is going on?

pip freeze returns (for some relevant packages only):

asyncio==3.4.3
requests==2.32.3
selenium==4.22.0
selenium-stealth==1.0.6
selenium_driverless==1.9.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions