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] elementHandle.scrollIntoViewIfNeeded doesn't work properly

See original GitHub issue

Context:

  • Playwright Version: 1.4.2
  • Operating System: Mac
  • Node.js version: 12
  • Browser: Chromium
  • Extra: NA

Describe the bug elementHandle.scrollIntoViewIfNeeded won’t scroll if the element is partially visible. I think this might be unexpected behavior but I don’t see any details about this method on CDP.

2020-10-14T02:00:16.457Z pw:api => elementHandle.scrollIntoViewIfNeeded started
2020-10-14T02:00:16.458Z pw:api   waiting for element to be visible and not moving
2020-10-14T02:00:16.481Z pw:api   element is visible and does not move
2020-10-14T02:00:16.482Z pw:api <= elementHandle.scrollIntoViewIfNeeded succeeded

Here’s the page with selected element that I am trying to scroll into view

Screen Shot 2020-10-13 at 7 12 35 PM

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
dgozmancommented, Nov 2, 2020

Sorry for the late response. I looked at this page, and there is a position:fixed header that covers the item, and we are not scrolling the item from under that header. Reduced repro:

<style>
* {
  padding: 0;
  margin: 0;
}
li {
  height: 80px;
  border: 1px solid black;
}
ol {
  padding-top: 104px;
}
div.fixed {
  position: fixed;
  z-index: 1001;
  width: 100%;
  background: red;
  height: 104px;
}
</style>

<div class=fixed></div>

<ol>
<li>hi1</li><li>hi2</li><li>hi3</li><li>hi4</li><li>hi5</li><li>hi6</li><li>hi7</li><li>hi8</li><li>hi9</li><li>hi10</li><li>hi11</li><li>hi12</li><li>hi13</li><li>hi14</li>
</ol>

0reactions
VikramTiwaricommented, Nov 9, 2020

Oh nice! I am glad you were able to recreate it in a standalone manner and that this is a known bug. Thanks for following up on this. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Element.scrollIntoViewIfNeeded() - Web APIs - MDN Web Docs
The Element.scrollIntoViewIfNeeded() method scrolls the current element into the visible area of the browser window if it's not already within ...
Read more >
html - Javascript: scrollIntoView() vs scrollIntoViewIfNeeded()
The Element.scrollIntoViewIfNeeded() method scrolls the current element into the visible area of the browser window if it's not already within ...
Read more >
ElementHandle | Playwright - CukeTest
This method waits for the actionability checks, then scrolls element into view before taking a screenshot. If the element is detached from DOM,...
Read more >
https://raw.githubusercontent.com/microsoft/playwr...
An example of handling a timeout error: ```js try { await page. ... "Incognito" browser contexts don't write any browsing data to disk....
Read more >
Playwright changelog - Awesome Node.js - LibHunt
#4038 - [REGRESSION]: Tall screenshots in chromium get corrupted at bottom #4134 - [BUG] elementHandle.scrollIntoViewIfNeeded doesn't work properly
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