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.

[BUG] scrollIntoView does not work when covered by sticky header in Chromium

See original GitHub issue

Context:

  • Playwright Version: 1.2.1
  • Operating System: Ubuntu Bionic (docker image)
  • Node version: 12.18.0 (ubuntu) / 12.16.2 (win)
  • Browser: HeadlessChrome/85.0.4182.0 (ubuntu)

Hello, guys. I am working on puppeteer -> playwright migration and faced an issue that did not happen with puppeteer, but happens with playwright for some reason.

I have a list of items, one of them is partially visible. Header overlaps it. I pointed my mouse over it and it’s highlighted at the moment: image

I use simple click with the only one parameter click count = 1. No other flags are set.

According to this doc: position <Object> A point to click relative to the top-left corner of element padding box. If not specified, clicks to some visible point of the element.

PW should click to some visible point of the element. But it does not happen:

Timeout 30000ms exceeded during page.click.
===================== page.click logs =====================
[api] waiting for selector "[data-test-id^="Nav.Country.222"]"
[api]   selector resolved to visible <div tabindex="0" role="button" aria-disabled="false"…>…</div>
[api] attempting page.click action
[api]   waiting for element to be visible, enabled and not moving
[api]   element is visible, enabled and does not move
[api]   scrolling into view if needed
[api]   done scrolling
[api]   checking that element receives pointer events at (149.5,187)
[api]   element does not receive pointer events
[api] retrying page.click action
[api]   waiting for element to be visible, enabled and not moving
[api]   element is visible, enabled and does not move
[api]   scrolling into view if needed
[api]   done scrolling
[api]   checking that element receives pointer events at (149.5,187)
[api]   element does not receive pointer events
[api] retrying page.click action
[api]   waiting for element to be visible, enabled and not moving
[api]   element is visible, enabled and does not move
[api]   scrolling into view if needed
[api]   done scrolling
[api]   checking that element receives pointer events at (149.5,187)
[api]   element does not receive pointer events
[api] retrying page.click action
[api]   waiting for element to be visible, enabled and not moving
[api]   element is visible, enabled and does not move
[api]   scrolling into view if needed
[api]   done scrolling
[api]   checking that element receives pointer events at (149.5,187)
[api]   element does not receive pointer events
[api] retrying page.click action
[api]   waiting for element to be visible, enabled and not moving
[api]   element is visible, enabled and does not move
[api]   scrolling into view if needed
[api]   done scrolling
[api]   checking that element receives pointer events at (149.5,187)
[api]   element does not receive pointer events
[api] retrying page.click action

I used https://chrome.google.com/webstore/detail/coordinates/bpflbjmbfccblbhlcmlgkajdpoiepmkd to check the coordinates and it seems that PW selects coordinates of invisible part. I am not 100% sure, because I was not able to reproduce the issue on Windows in debug mode, but it happens often with docker tests. image

I’ll be happy to provide some additional info for you, just let me know.

Update: As a workaround I added one scroll into view for the element to be sure that it’s fully visible and ready for clicks. But it would be nice to have a permanent solution.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
dgozmancommented, Jul 24, 2020

My guess would be that target element [data-test-id^="Nav.Country.222"] is actually covered by some other element that receives the input. If that’s the case, pass force to click on the overlay element instead.

await page.click('[data-test-id^="Nav.Country.222"]', { force: true });

If this is not the case, the repro script would be very welcome 😄

1reaction
dgozmancommented, Jul 24, 2020

@DJ-Glock Thank you for the snippet! I can repro this in Chromium, but not Firefox or WebKit. It seems like Chromium is unable to scroll the target into view from under the sticky header.

Read more comments on GitHub >

github_iconTop Results From Across the Web

664246 - scrollIntoView or linking to a scroll anchor on a sticky ...
Issue 664246: scrollIntoView or linking to a scroll anchor on a sticky element should scroll to the normal flow position. Reported by schedule ......
Read more >
scrollIntoView Scrolls just too far - Stack Overflow
The issue is that it goes just a tad too far. Like the option they are on is about 10px too high. So,...
Read more >
Prevent content from being hidden underneath a fixed header ...
Fixed headers have a nasty habit of hiding the element you're trying to link to ... As noted in the comments below this...
Read more >
Sticky, Smooth, Active Nav - CSS-Tricks
Uses sticky positioning. It stays on the screen when it can, but won't overlap the header, footer, or ever make any of it's...
Read more >
An event for CSS position:sticky - Chrome Developers
However, that gets pretty tricky to do without scroll events :) The other problem is that position:sticky removes the element from layout ......
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