pyppeteer icon indicating copy to clipboard operation
pyppeteer copied to clipboard

Execution context was destroyed, most likely because of a navigation.

Open wonghang opened this issue 4 years ago • 2 comments

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

wonghang avatar Mar 24 '20 04:03 wonghang

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 avatar Mar 27 '20 00:03 Mattwmaster58

@Mattwmaster58 thanks. Let me check it out and see if it fixes the problem.

wonghang avatar Mar 27 '20 02:03 wonghang