question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] "Unable to retrieve content because the page is navigating and changing the content." after reload() and content() in sequence

See original GitHub issue

Context:

  • Playwright Version: 1.24.0 (also observed in 1.21)
  • Operating System: Windows, Debian
  • Python version: 3.8
  • Browser: only Chrome based (both chromium and chrome)
  • Extra: does not occur with reload(wait_until="networkidle")

Code Snippet

import asyncio

from playwright.async_api import async_playwright

async def mvp():
    TRIGGER_URL = "http://www.vs-sm.de/ "
    async with async_playwright() as p:
        b = await p.chromium.launch()

        page = await b.new_page()
        await page.goto(TRIGGER_URL, timeout=30000)
        await page.reload(wait_until="networkidle")
        await page.content()
        print("wait_until=\"networkidle\" works")

        await page.goto(TRIGGER_URL, timeout=30000)
        await page.reload()
        await page.content()


asyncio.run(mvp())

Describe the bug

Traceback (most recent call last):
  File "C:/Users/Matt Marcus/AppData/Roaming/JetBrains/PyCharm2022.2/scratches/scratch_71.py", line 21, in <module>
    asyncio.run(mvp())
  File "C:\Program Files\Python38\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "/AppData/Roaming/JetBrains/PyCharm2022.2/scratches/scratch_71.py", line 18, in mvp
    await page.content()
  File "venv\lib\site-packages\playwright\async_api\_generated.py", line 7180, in content
    return mapping.from_maybe_impl(await self._impl_obj.content())
  File "venv\lib\site-packages\playwright\_impl\_page.py", line 479, in content
    return await self._main_frame.content()
  File "venv\lib\site-packages\playwright\_impl\_frame.py", line 400, in content
    return await self._channel.send("content")
  File "venv\lib\site-packages\playwright\_impl\_connection.py", line 43, in send
    return await self._connection.wrap_api_call(
  File "C:\Users\Matt Marcus\Documents\Projects\gdprscan\venv\lib\site-packages\playwright\_impl\_connection.py", line 369, in wrap_api_call
    return await cb()
  File "C:\Users\Matt Marcus\Documents\Projects\gdprscan\venv\lib\site-packages\playwright\_impl\_connection.py", line 78, in inner_send
    result = next(iter(done)).result()
playwright._impl._api_types.Error: Unable to retrieve content because the page is navigating and changing the content.

Process finished with exit code 1

Related: microsoft/playwright-python#1454

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
Mattwmaster58commented, Aug 13, 2022

Great to hear this. I’m assuming this is going to land in 1.26 based off the labels?

cc @joe733 might be interested in this bug resolution

1reaction
dgozmancommented, Aug 11, 2022

Investigated this in chromium:

  • Page.lifecycleEvent(load) arrives - page.goto() resolves.
  • page.reload() issues a reload command.
    • Page.navigatedWithinDocument arrives because page did a pushState - reload resolves the “waitForNavigation” bit.
    • 'load' event is already there, so reload does not wait for for it and resolves.
  • page.content() starts and issues an evaluate.
  • Now the page actually issues a network request for the reload, gets a response, commits and clears execution contexts.
  • page.content() fails.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Playwright error (Target closed) after navigation - Stack Overflow
So simple, but I can't get it to work. This is the code: const playwright = require('playwright'); (async () => { ...
Read more >
Page | Playwright - CukeTest
Gets the full HTML contents of the page, including the doctype. page.context()#. returns: <BrowserContext>#. Get the browser context that the page belongs to....
Read more >
Troubleshoot Data Sources - Tableau Help
To update the Connect to Data page in Tableau Desktop, click the Refresh icon: Unable to connect to this Tableau Server data source:...
Read more >
Troubleshoot—ArcGIS Online Help | Documentation
My basemap is unavailable, so none of my map content appears. When I add an OGC WMS or WMTS layer to my map,...
Read more >
Focus Order - Understanding Success Criterion 2.4.3 - W3C
2) as long as the user can still understand and operate the Web page. Since there may be several possible logical reading orders...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found