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.

[Question] FullPageScreenshot is not capturing the full page

See original GitHub issue

Hi - I have the following script to capture the full page screenshot

@Test
    public void googleTest(){
       Playwright playwright = Playwright.create();
        BrowserType.LaunchOptions launchOptions = new BrowserType.LaunchOptions();
        launchOptions.setHeadless(false)
                .setChannel(BrowserChannel.CHROME);
        Browser browser = playwright.chromium().launch(launchOptions);
        BrowserContext browserContext = browser.newContext();
        Page page = browserContext.newPage();
        page.navigate("https://google.com");
        page.click("text=I agree");
        System.out.println(page.title());
        page.screenshot(new Page.ScreenshotOptions()
                .setPath(Paths.get("colosseum-pixel2.png"))
                .setFullPage(true)
        );

    }

The script runs fine and it takes the screenshot at the end. But the screenshot is not full page. Please refer attached the screenshot.

Screenshot-Taken-By-Playwright

I am running this script using Playwright 1.10.0 OS - Ubuntu 20.04.2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
regbocommented, May 21, 2021

Below is a simple test (using 1.11.0) that illustrates the issue.

Here’s the images outputted: https://imgur.com/a/O3C0Dw7

package test;

import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;

import com.microsoft.playwright.Browser;
import com.microsoft.playwright.BrowserContext;
import com.microsoft.playwright.BrowserType;
import com.microsoft.playwright.BrowserType.LaunchOptions;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;

public class ScreenshotTest {

	public static void main(String[] args) {
		try (Playwright playwright = Playwright.create()) {
			List<BrowserType> browserTypes = Arrays.asList(playwright.chromium(), playwright.firefox());
			for (BrowserType browserType : browserTypes) {
				for (var headless : List.of(false, true)) {
					for (var swiftshader : List.of(false, true)) {
						var launchOptions = new LaunchOptions().setHeadless(headless);
						if (swiftshader)
							launchOptions.setArgs(List.of("--use-gl=swiftshader"));
						try (Browser browser = browserType.launch(launchOptions)) {
							BrowserContext context = browser.newContext();
							Page page = context.newPage();
							page.navigate(
									"https://stackoverflow.com/questions/33770549/viewport-vs-window-vs-document");
							var path = Paths.get(String.format("temp/screenshot-%s-%s-%s-%s.png", browserType.name(),
									headless ? "headless" : "headfull", swiftshader ? "swiftshader" : "defaultshader",
									UUID.randomUUID().toString()));
							page.screenshot(new Page.ScreenshotOptions().setFullPage(true).setPath(path));
							System.out.println(path.toFile().getAbsolutePath());
						}
					}
				}
			}
		}
	}
}

2reactions
reggiepiercecommented, May 11, 2021

I can confirm that this is happening. It looks like the viewport gets squashed right before the screenshot is rendered

Read more comments on GitHub >

github_iconTop Results From Across the Web

Full Page Screenshot function not working. - Apple Community
I took a screenshot from safari to take a full page but it does not give me the option to a full page....
Read more >
Not able to run puppeteer-full page screenshot npm package
You need to call the default() function of fullPageScreenshot to make it work: import puppeteer from 'puppeteer'; import fullPageScreenshot ...
Read more >
iPhone: Fix Full-Page Screenshots on Safari Not Working ...
Learn how you can fix the full page screenshots on Safari not working or the option is missing on iPhone.Gears I use:iPhone 13...
Read more >
screenshot enabled … but does not 'capture' full page.
There seems to be a size limit for full page screenshots, so a very very large page a full page screenshot won't work...
Read more >
Full page screenshot does not work properly when a ... - GitHub
I'm suppose the best way to capture that page is to just capture the fixed position item at the end of the page....
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