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] Default viewport config doesn't set viewport to selected size

See original GitHub issue

Context:

  • 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:closed
  • Created a year ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
tsvetkovamariacommented, Nov 22, 2022

Maybe it’s worth mentioning it in the docs, as it took me a while to figure out the reason of viewport not applied.

1reaction
pavelfeldmancommented, Apr 28, 2022

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):

use: {
  ...devices["Desktop Chrome"],
}

You can replace ...devices with browserName: 'firefox' if you only want to set the browser and not define the whole preset that includes browser, user agent, viewport. etc/

Read more comments on GitHub >

github_iconTop 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 >

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