[BUG] Default viewport config doesn't set viewport to selected size
See original GitHub issueContext:
- Playwright Version: 1.21.1
- Operating System: Windows & ArchLinux
- Node.js version: 16.14.2
- Browser: Chromium, Firefox
Code Snippet
import type { PlaywrightTestConfig } from "@playwright/test";
import { devices } from "@playwright/test";
const config: PlaywrightTestConfig = {
testDir: "./tests",
timeout: 30 * 1000,
expect: {
timeout: 5000,
},
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: [["junit", { outputFile: "results.xml" }]],
use: {
actionTimeout: 0,
baseURL: "localhost",
trace: "on",
video: {
mode: "on",
size: {
width: 1920,
height: 1080,
},
},
viewport: {
width: 1920,
height: 1080,
},
},
projects: [
{
name: "chromium",
use: {
...devices["Desktop Chrome"],
},
},
{
name: "firefox",
use: {
...devices["Desktop Firefox"],
},
},
],
};
export default config;
Describe the bug
Hello,
I’m trying to set a default viewport for my test to 1920x1080, but when i’m putting this configuration into playwright.config.ts
file, the current viewport is always 800x800. The unique workaround I found is to set manualy the viewport size of each page on my test file by doing await page.setViewportSize({ width: 1920, height: 1080 });
.
Did I miss something?
Issue Analytics
- State:
- Created a year ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
1501665 - Enabling meta viewport breaks the viewport (-size)
It always happens to me and I can't find a case where it doesn't. Maybe the key is that the RDM viewport size...
Read more >Viewport is not visible and cannot be selected or adjusted in ...
Solution: · On the command line type QSELECT. · Select 'Viewports' from the drop down list and click 'Ok'. · Move viewport to...
Read more >viewport settings improper sites locked at reduced scale
Issue 458782: viewport settings improper sites locked at reduced scale ... a rendered object scaled normal or as set in preferences. What happens...
Read more >How to fix iOS Viewport Bug(s)? - Stack Overflow
Have you tried initial-scale=1, maximum-scale=1, user-scalable=no ? Also, I think you are trying to fix it backwards.
Read more >Maya: Tool Fix Viewport - Create 3d Characters
The Fix Viewport tool easily corrects and makes Maya's viewport ... the default will be as per lamberts/blinns/phongs, so this setting is ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Maybe it’s worth mentioning it in the docs, as it took me a while to figure out the reason of viewport not applied.
Global viewport size is the default value to use for all the projects. The problem here is that the following code in your project overwrites it (device includes viewport size):
You can replace
...devices
withbrowserName: 'firefox'
if you only want to set the browser and not define the whole preset that includes browser, user agent, viewport. etc/