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.

ElementHandle screenshot doesn't work properly when the element is offscreen

See original GitHub issue

Tell us about your environment:

  • Puppeteer version: 5.3.0
  • Platform / OS version: Fedora 32
  • Node.js version: 12.18.3

What steps will reproduce the problem?

let’s say we have a page where there are “card” divs

<div class="card">blah blah</div>
<div class="card">blah blah blah</div>

const cards = await page.$$("div.card");
  
for (const [idx, card] of cards.entries()) {
  await card.screenshot({
    path: `pnl${idx}.png`
  });
}

specifically, this happens on ftx.com/shareable-pnl, like this: element 1 element 2, wrong

What is the expected result? proper screenshots

What happens instead? the screenshot for the first card will come out fine, the second one comes incorrectly cropped from halfway to the bottom plus

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
whoisjuancommented, Oct 1, 2020

@whoisjuan found a workaround? do you remember what was the last version that worked?

@mikelpr Yep. Unfortunately, you will have to downgrade a lot. This happened when 2.0.0 was released. Here is the feedback issue for that specific change: https://github.com/puppeteer/puppeteer/issues/5080 I asked yesterday if there was a workaround yet and it seems that they have been talking about it recently: https://bugs.chromium.org/p/chromium/issues/detail?id=1003629#c11

So give it a try with https://github.com/puppeteer/puppeteer/releases/tag/v1.20.0 and if that solves your problem, then it means that your issue is indeed related to this change. But I’m like 95% sure that this is your problem.

0reactions
stale[bot]commented, Jul 26, 2022

We are closing this issue. If the issue still persists in the latest version of Puppeteer, please reopen the issue and update the description. We will try our best to accomodate it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Puppeteer in NodeJS reports 'Error: Node is either not visible ...
I'm using 'puppeteer' for NodeJS to test a specific website. It seems to work fine in most ...
Read more >
Is there a way to do 'print screen' capturing areas off screen?
Here's another one that installs locally: Fireshot. It works for Firefox and IE. Here's a sample screenshot of SuperUser, click for hi-res:.
Read more >
ElementHandle.screenshot() method - Puppeteer
ElementHandle.screenshot() method. This method scrolls element into view if needed, and then uses Page.screenshot() to take a screenshot of the element.
Read more >
.scrollIntoView() | TestController | Test API | API | Docs
When TestCafe interacts with an off-screen DOM element, it scrolls that element into view. ... target, Function | String | Selector | Snapshot...
Read more >
Puppeteer screenshot element, page or area - Pocket Admin
To take in puppeteer screenshot element you must run ElementHandle.screenshot(). Examples of how to take screenshot in puppeteer 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