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
64.05k stars 3.47k forks source link

[BUG] Full-page screenshot in headful mode got replicated portions for website with big height #28834

Closed wbeuil closed 6 months ago

wbeuil commented 6 months ago

Seems like the page.screenshot is not running exactly the same between headless and headful for websites with big height. The headful one got multiple replicated portions of the website, whereas the headless one is what I want. Please find below a way to replicate my issue.

System info

Source code

const playwright = require('playwright');

async function takeScreenshot(browser, path) {
  const url = "https://fr.wikipedia.org/wiki/Paris"
  const page = await browser.newPage()
  await page.goto(url)
  await page.screenshot({ path, fullPage: true })
  await page.close()
  await browser.close()
}

(async () => {
  const browser1 = await playwright.chromium.launch({ headless: true })
  await takeScreenshot(browser1, 'screenshot-1.png')
  const browser2 = await playwright.chromium.launch({ headless: false })
  await takeScreenshot(browser2, 'screenshot-2.png')
})()

Steps

Expected

The full page website as the headless one.

Actual

The headful screenshot got replicated portions of the website.

mxschmitt commented 6 months ago

Folding into https://github.com/microsoft/playwright/issues/12683.