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

[BUG] Chromium: screenshot is created without scrollbars #5778

Closed
DJ-Glock opened this issue Mar 10, 2021 · 2 comments
Closed

[BUG] Chromium: screenshot is created without scrollbars #5778

DJ-Glock opened this issue Mar 10, 2021 · 2 comments

Comments

@DJ-Glock
Copy link

DJ-Glock commented Mar 10, 2021

Context:

  • Playwright Version: playwright-chromium 1.9.2
  • Operating System: Windows (also can be reproduced on a Linux, using PW docker image)
  • Node.js version: 12.18.3
  • Browser: Chromium
  • Extra: can be reproduced with React based sites.

Code Snippet
Here you are a code sample that can reproduce the issue

// @ts-check
const playwright = require("playwright-chromium");

(async () => {
  const browser = await playwright.chromium.launch({
    // Change it according your needs
    headless: true,
    slowMo: 100,
    args: [
      '--start-maximized',
      // '--window-size=1920,1080',
      '--no-sandbox',
      '--disable-setuid-sandbox',
      '--disable-dev-shm-usage',
      '--enable-logging',
    ]
  });
  const context = await browser.newContext({viewport:{width:1920,height:1080}});
  // const context = await browser.newContext();
  const page = await context.newPage();
  await page.goto('https://devexpress.github.io/devextreme-reactive/react/grid/docs/guides/virtual-scrolling/', { timeout: 60000 });
  await page.waitForTimeout(3000);

  const demo = await page.waitForSelector('[class="embedded-demo"]');
  await demo.scrollIntoViewIfNeeded();

  await page.screenshot({ path: './screenshots/test.png' });

  await browser.close();
})();

Describe the bug
When PW takes a screenshot of React based grid, scrollbars disappeared.

What you see in your browser:
image

What you can see on PW screenshot of the page:
image

@yury-s
Copy link
Member

yury-s commented Mar 10, 2021

This is specific to headless mode where playwright hides scrollbars by default. You can override this behavior by changing your launch code like this:

const browser = await playwright.chromium.launch({
  ignoreDefaultArgs: [
    '--hide-scrollbars'
  ],
  // other options
});

@yury-s yury-s closed this as completed Mar 10, 2021
@nickofthyme
Copy link
Contributor

Alternatively, this can be set in the playwright config...

// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';

const config: PlaywrightTestConfig = {
  use: {
    headless: true,
    launchOptions: {
      ignoreDefaultArgs: ['--hide-scrollbars'],
    },
  },
  projects: [
    {
      name: 'chrome',
      use: {
        browserName: 'chromium',
        launchOptions: {
          ignoreDefaultArgs: false, // overrides top-level `use` value
        },
      },
    },
  ],
};
export default config;

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

3 participants