pydoll icon indicating copy to clipboard operation
pydoll copied to clipboard

TimeoutError on getting page source

Open Ehsan-U opened this issue 1 year ago • 0 comments

I tried the example and even that is not working, page was fully loaded. page_source is triggering the TimeoutError


import asyncio
from pydoll.browser.chrome import Chrome

async def main():
    async with Chrome() as browser:
        await browser.start()
        page = await browser.get_page()
        
        await page.go_to('https://www.rei.com/c/mens-boots')
        await page._wait_page_load()
        content = await page.page_source
        print(content)

asyncio.run(main())

Traceback:

raceback (most recent call last):
  File "/usr/lib/python3.12/asyncio/tasks.py", line 520, in wait_for
    return await fut
           ^^^^^^^^^
asyncio.exceptions.CancelledError

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

Traceback (most recent call last):
  File "/home/ehsan/projects/personal/scrapy-pydoll/_test.py", line 58, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/ehsan/projects/personal/scrapy-pydoll/_test.py", line 56, in main
    content = await page.page_source
              ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ehsan/projects/personal/scrapy-pydoll/.venv/lib/python3.12/site-packages/pydoll/browser/page.py", line 96, in page_source
    response = await self._execute_command(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ehsan/projects/personal/scrapy-pydoll/.venv/lib/python3.12/site-packages/pydoll/mixins/find_elements.py", line 239, in _execute_command
    return await self._connection_handler.execute_command(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ehsan/projects/personal/scrapy-pydoll/.venv/lib/python3.12/site-packages/pydoll/connection/connection.py", line 126, in execute_command
    raise exc
  File "/home/ehsan/projects/personal/scrapy-pydoll/.venv/lib/python3.12/site-packages/pydoll/connection/connection.py", line 122, in execute_command
    response: str = await asyncio.wait_for(future, timeout)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/tasks.py", line 519, in wait_for
    async with timeouts.timeout(timeout):
  File "/usr/lib/python3.12/asyncio/timeouts.py", line 115, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

Ehsan-U avatar Mar 17 '25 04:03 Ehsan-U