microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
66.39k stars 3.63k forks source link

[Bug]: Screenshot does not capture scrollbar #30228

Open jpEngProd opened 6 months ago

jpEngProd commented 6 months ago

Version

1.42.0

Steps to reproduce

  1. Create a .net project with Playwright.Microsoft nuget package.
  2. Add below code in Program.cs
using Microsoft.Playwright;

var browserLaucnhOptions = new BrowserTypeLaunchOptions
{
    Headless = false,
    Timeout = 60000
};

var playwright = await Playwright.CreateAsync();

var browser = await playwright.Chromium.LaunchAsync(browserLaucnhOptions);

var page = await browser.NewPageAsync();
await page.GotoAsync("https://www.bing.com/search?q=scrollbar+in+a+page");
await page.ScreenshotAsync(new PageScreenshotOptions { Path = "screenshot.png", FullPage = true });
await browser.CloseAsync();``

Expected behavior

Screenshot with scrollbar.

image

Actual behavior

Below is the captured screenshot. It does not contain scrollbar.

screenshot

Additional context

Also tried configuring --hide-scrollbars as mentioned in few threads. That also doesnb

var browserLaucnhOptions = new BrowserTypeLaunchOptions
{
    IgnoreDefaultArgs = new List<string>() { "--hide-scrollbars" },
    Headless = false,
    Timeout = 60000
};

Environment

OS: Windows
Playwright version: 1.42.0
Dotnet version: 8.0
Browser: Chrome
dgozman commented 6 months ago

@jpEngProd Scrollbars are currently hidden in headless mode. I understand that it is sometimes desirable to see scrollbars in the screenshot, but there is no control over scrollbars in Playwright API yet.

jpEngProd commented 6 months ago

Even for non-headless mode scrollbars are hidden. I have added Headless = false in above provided code snippets