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
[Question] FullPageScreenshot is not capturing the full page #436
Comments
Hi Yury, Please find below the chrome version. I am located in UK, I get Cookies Consent popup with two options to click ''customise' and 'I agree' as part of GDPR .
|
Got you about GDPR dialog. Is it reproducible in headless mode ( |
Yes, thank you!
Yes, I see. Does the problem reproduce if you drop |
I can confirm that this is happening. It looks like the viewport gets squashed right before the screenshot is rendered |
It seems to be a timing issues, basically not all tiles of the page image are rasterized by the time the snapshot is taken. @senthilkumar10 @reggiepierce To validate that, could you insert timeout before the screenshot to give the browser time to render: ...
page.click("text=I agree");
System.out.println(page.title());
page.waitForTimeout(1000);
page.screenshot(new Page.ScreenshotOptions()
... You can also open DevTools on the page and in the Console drawer > Rendering tab (you may have to click ⋮ menu to open it) enable It will draw the tiles grid, our hypothesis is that some of the tiles are not rendered yet when the screenshot is taken, on my machine it looks like this: |
I have added the page wait from 1000 and increased up till 5000 but still the screenshots is not full page. |
Hmm, thanks for trying that's weird 🤔 Can you also try with this argument: ...
launchOptions.setHeadless(false)
.setArgs(Collections.singletonList("--use-gl=swiftshader"))
.setChannel(BrowserChannel.CHROME);
... It will force Chrome to use software sharer implementation (which is what is used in headless I believe). |
@senthilkumar10 does it work if you just remove |
I ran the following tests Test 1 :- ''' removed '.setFullPage(true) Result - Screenshot is not FullPage Test 2:- ''' with '.setFullPage(true) Result - Screenshot is not FullPage Test 3:- ''' with '.setFullPage(true) Result - Screenshot is FullPage Test 4:- ''' removed '.setFullPage(true) Result - Screenshot is FullPage |
So in headful mode passing "--use-gl=swiftshader" solves the problem and you get entire page captured regardless of |
Sorry for the confusion. In headful mode (launchOptions.setHeadless(false)) passing "--use-gl=swiftshader" also doesn't solves the problem regardless of '''setFullPage''' value |
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());
}
}
}
}
}
}
} |
I think this may be an underlying driver problem: |
Although the bug you referenced looks different (as it has to do with element screenshot) the problem described in this issue is certainly a driver or more precisely Chromium problem. Unfortunately we haven't been able to reproduce it locally so far which makes it hard to debug. It may be specific to some graphics cards, what does |
I get the below output *-display |
Closing as part of the triage process since it seemed stale. Please create a new issue with a detailed reproducible if you still face issues with Playwright for Java. |
Hi - I have the following script to capture the full page screenshot
The script runs fine and it takes the screenshot at the end. But the screenshot is not full page. Please refer attached the screenshot.
I am running this script using Playwright 1.10.0
OS - Ubuntu 20.04.2
The text was updated successfully, but these errors were encountered: