Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Puppeteer launched Chrome window doesn't resize viewport on window resize #3688

Closed
prabh-62 opened this issue Dec 18, 2018 · 3 comments
Closed

Comments

@prabh-62
Copy link

prabh-62 commented Dec 18, 2018

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: Google Chrome | 71.0.3578.98 (Official Build) (64-bit) (cohort: Stable)
{
"_isPuppeteerCore": true,
"_preferredRevision": "609904"
}
  • Platform / OS version: Windows 10.0.17763 N/A Build 17763
  • URLs (if applicable):
  • Node.js version:10.9.0

What steps will reproduce the problem?
Please include code that reproduces the issue.

const puppeteer = require('puppeteer-core');

(async () => {
  const browser = await puppeteer.launch({
    headless: false,
    executablePath:
      'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe'
  });

  const pages = await browser.pages();
  const page = pages[0];
  await page.goto('https://google.com');
})();
  1. Run this code snippet
  2. Resize google chrome Window
  3. Google Homepage does not respond to resizes as well as window.onresize doesn't work
// doesn't work
window.onresize = (e) => console.log(e)

What is the expected result?
webpage should respond to window resizes by the user just like normal Google Chrome app

What happens instead?
webpage doesn't respond to any window resize by the user
puppeteer

Further info:

  • I have researched github issues, stack overflow and found help. However after updating to Chrome 71 since yesterday, nothing works. I can't rely on CDP session if it would break from Chrome 70 to Chrome 71.
  • Setting --window-size launch argument and page.setViewport does work for initial launch however, what to do when user manually resizes after launch.
  • In chrome 71 in --app mode, page._client.send('Emulation.clearDeviceMetricsOverride'); doesn't work
  • Why is the experience different from normal Google Chrome app?
    chrome
@prabh-62 prabh-62 changed the title Puppeteer launched Chrome window doesn't resize on window resize Puppeteer launched Chrome window doesn't resize viewport on window resize Dec 18, 2018
@bWhirring
Copy link

I don't know the reason, but I open the console and closed resolve it

@aslushnikov
Copy link
Contributor

@prabh-62 Puppeteer emulates viewport by default, so window resizing doesn't affect viewport.
If you don't like the behavior and want viewport to match the window size, you should launch chrome with defaultViewport: null option.

const puppeteer = require('puppeteer-core');

(async () => {
  const browser = await puppeteer.launch({
    headless: false,
    defaultViewport: null,
    executablePath:
      'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe'
  });

  const pages = await browser.pages();
  const page = pages[0];
  await page.goto('https://google.com');
})();

@mudassarbhinder
Copy link

I also facing same issue

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

No branches or pull requests

4 participants