[BUG] PW always ignores the specified viewport
See original GitHub issueContext:
- 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:
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:
- Created a year ago
- Comments:7 (7 by maintainers)
has viewport defined in it, so you are overriding your top-level definition.
Try editing your project.config like so:
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!