Skip to content
This repository has been archived by the owner on May 8, 2020. It is now read-only.

pyppeteer fails in a simple test case where pupeteer does not #19

Closed
davepeck opened this issue Jan 26, 2018 · 3 comments
Closed

pyppeteer fails in a simple test case where pupeteer does not #19

davepeck opened this issue Jan 26, 2018 · 3 comments

Comments

@davepeck
Copy link

davepeck commented Jan 26, 2018

I tried a small comparative test; this puppeteer code works and successfully takes a screenshot:

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://davepeck.org/');
  await page.screenshot({path: '/tmp/dave-js.png'});

  await browser.close();
})();

The equivalent pyppeteer code does not work:

import asyncio
from pyppeteer.launcher import launch

async def main(browser):
    page = await browser.newPage()
    await page.goto('https://davepeck.org/')
    await page.screenshot({'path': '/tmp/dave-py.png'})

browser = launch()
asyncio.get_event_loop().run_until_complete(main(browser))
browser.close()

It hits its 3 second navigation timeout; explicitly setting a different timeout (something that will definitely be long enough to load the page in question, like await page.goto('https://davepeck.org/', timeout=150000)) similarly fails.

Details:
- Pyppeteer: Python 3.6.4, Pyppeteer 0.0.9, chromium revision 497674 (62.0.3198.0), macOS 10.13.3
- Puppeteer: Node 9.4.0, Puppeteer 1.0.0, chromium revision 526987 (65.0.3312.0), macOS 10.13.3

Thoughts:
- It wouldn't surprise me if the very different chromium versions are to blame, although I'm not certain.
- I noticed this with my personal blog, but I suspect we'll find similar behavior for other pages?

Happy to test whatever you'd like.

@davepeck
Copy link
Author

Update: I explicitly monkey-patched pyppeteer.chromium_downloader.chromium_excutable() to return the build of chromium packaged with puppeteer. This did not appear to change the behavior.

@hixi
Copy link

hixi commented Apr 11, 2018

Have you tried launching the browser in the async function?

From my understanding, this is how it is supposed to work and be used:

import asyncio
from pyppeteer.launcher import launch

async def main():
    browser = await launch()
    page = await browser.newPage()
    await page.goto('https://davepeck.org/')
    await page.screenshot({'path': '/tmp/dave-py.png'})
    await browser.close()

asyncio.get_event_loop().run_until_complete(main())

@misolietavec
Copy link

Yes, @hixi , works for me even in Python 3.5.3.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants