pyppeteer
pyppeteer copied to clipboard
Execution context was destroyed, most likely because of a navigation.
Hi, I have a webpage having a button to go to next page and then I want to click it. I follow the document written in https://miyakogi.github.io/pyppeteer/reference.html and use the following pattern:
await asyncio.gather(
page.waitForNavigation(),
page.click("#foobar"),
)
Most of time, it works fine. But occasionally, I will get the following errors:
File "/usr/local/lib/python3.7/dist-packages/pyppeteer/page.py", line 1548, in click
await frame.click(selector, options, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/pyppeteer/frame_manager.py", line 581, in click
handle = await self.J(selector)
File "/usr/local/lib/python3.7/dist-packages/pyppeteer/frame_manager.py", line 317, in querySelector
value = await document.querySelector(selector)
File "/usr/local/lib/python3.7/dist-packages/pyppeteer/element_handle.py", line 360, in querySelector
self, selector,
File "/usr/local/lib/python3.7/dist-packages/pyppeteer/execution_context.py", line 108, in evaluateHandle
_rewriteError(e)
File "/usr/local/lib/python3.7/dist-packages/pyppeteer/execution_context.py", line 237, in _rewriteError
raise type(error)(msg)
pyppeteer.errors.NetworkError: Execution context was destroyed, most likely because of a navigation.
Any idea or workaround?
I am using the following version of pyppeteer:
$ python3.7 -m pip list | grep pyppeteer
pyppeteer (0.0.25)
I think it is a related issue: https://github.com/puppeteer/puppeteer/issues/5056
Hi @wonghang , it looks like this project has been abandoned. You may want to consider the active fork pyppeteer2. Feel free to create an issue there if your problem persists with the updated library.
@Mattwmaster58 thanks. Let me check it out and see if it fixes the problem.