-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[BUG] scrollIntoView does not work when covered by sticky header in Chromium #3105
Comments
Thank you for filing the issue, I will look into this. However, sample script or at least a page url would be very much appreciated! |
I tried to reproduce something like this, but it works for me locally. const {chromium} = require('playwright');
(async () => {
const browser = await chromium.launch({headless: false, slowMo: 100});
const context = await browser.newContext();
const page = await context.newPage();
await page.setContent(`
<div style='overflow: scroll; width: 200px; height: 85px; border: 1px solid black;'>
<div style='height: 20px; width: 150px'>div1</div>
<div style='height: 20px; width: 150px'>div2</div>
<div id=target
style='height: 20px; width: 150px; background: red;'
onclick='alert("clicked")'>div3</div>
<div style='height: 20px; width: 150px'>div4</div>
<div style='height: 20px; width: 150px'>div5</div>
<div style='height: 20px; width: 150px'>div6</div>
<div style='height: 20px; width: 150px'>div7</div>
</div>
`);
await page.$eval('div', div => div.scrollTop = 55);
await page.waitForTimeout(3000);
await page.click('#target');
await page.waitForTimeout(3000);
await browser.close();
})(); Note the red target div - we only see bottom 5 pixels of it when clicking, and it gets scrolled into view. |
My guess would be that target element await page.click('[data-test-id^="Nav.Country.222"]', { force: true }); If this is not the case, the repro script would be very welcome 😄 |
@dgozman thanks for your code sample. I dived deep into this issue and found the way to reproduce it. Here you are the code sample:
I suppose that PW is not able to determine if element is visible or not being under the title h6 with sticky position. |
@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. |
@DJ-Glock One more thing: you said this issue did not happen with puppeteer. Since both puppeteer and playwright use the same Chrome Debugging Protocol under the hood, this sounds interesting. I tried the same snippet with puppeteer (adding |
@dgozman I have just double checked our project with puppeteer and it looks like you're right. Puppeteer does not log any error, does not scroll the item under the sticky title, it just clicks with no effect. |
{ force: true } works for me |
Context:
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:
I use simple click with the only one parameter click count = 1. No other flags are set.
According to this doc:
position 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:
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.
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.
The text was updated successfully, but these errors were encountered: