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] PW always ignores the specified viewport

See original GitHub issue

Context:

  • Playwright Version: 1.21.1
  • Operating System: Manjaro Linux, Windows 10/11
  • Node.js version: v16.14.2
  • Browser: Chromium, Chrome
  • Monitor resolutions: 2560x1600 and 1920x1080

Code Snippet Here’s the relevant part from my config:

use: {

    headless: false,
    launchOptions: {
      //slowMo: 100
    },
    screenshot: 'on',
    trace: 'on',
    video: {mode:'on', size: {width: 1920, height: 1080}},
    viewport: { width: 1920, height: 1080 },
  },

  projects: [
    {
      name: 'chromium',

      /* Project-specific settings. */
      use: {
        ...devices['Desktop Chrome'],
        launchOptions: {
          headless: false,
          //args: ["--start-maximized", '--window-size=1920,1080'],
          //args: ["--start-maximized"],
        },
      },
    },

FYI the args: are commented out because they don’t work. Playwright simply ignores them too and always opens a non-maximized window in 1280x720 instead.

Describe the bug Despite defining the viewport as 1920x1080, Playwright always ignores this setting and instead opens a browser window of the size 1730x1052 with a viewport of 1731x942. Yes the viewport is really slightly wider than the top part of the browser with the address bar and browser tabs, see here: image

I’ve also tried putting the viewport into either of the launchOptions blocks, but then my IDE complains that ‘viewport’ does not exist in type ‘LaunchOptions’.

Funnily enough, the video testoption actually puts out a 1920x1080 video, but with black bars around it because the viewport is smaller.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
rwollcommented, May 13, 2022
 ...devices['Desktop Chrome'],

has viewport defined in it, so you are overriding your top-level definition.

Try editing your project.config like so:

      /* Project-specific settings. */
      use: {
        ...devices['Desktop Chrome'], // this includes a viewport (you can `console.log(devices['Desktop Chrome'])` to see what it's adding
        viewport: { width: 1920, height: 1080 }, // override what's coming in through the spread from above
      },
0reactions
azad-derakhshani-GScommented, May 23, 2022

Yeah exactly, I had used the executablePath option, but I’ve since switched back to Chromium for now.

Anyway, thanks for all your help and insights, really appreciate it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

html - React - Viewport being ignored - Stack Overflow
Try using meta(name='viewport', content='width=device-width, initial-scale=1.0') in your index.pug file. Based on your code, ...
Read more >
Bug - Viewport is incorrect in a custom pass running in ...
I have a script that needs to render things in world space *after* post-processing effects. This works perfectly using a custom HDRP pass...
Read more >
53707 – Viewport Warning/Error Messages Are Now Inaccurate
The test I'm proposing is: 7. <meta name="viewport" content="width="> ERROR: Viewport argument value "" for key "width" not recognized. Content ignored.
Read more >
[meta] Make viewport handling consistent with other browsers
Issues in Layout that do not fit into any other Layout component or which span multiple Layout components. Bugs related to the top...
Read more >
Safari Technology Preview Release Notes - Apple Developer
Safari Extensions. Fixed an issue where browser.tabs sometimes returned an incorrect URL for pinned tabs. Bug Fixes. Fixed the ...
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