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]: ElementHandle.click() in cross-origin iframes is off target in non-headless mode #7849
Comments
I was able to work around this by calculating the correct position using
(Obviously there’s some work in figuring out what frame(s) to check in order to make that generic.) |
I am unable to reproduce it. Was it an out of process iframe? |
This is my script. Do you have an exact script that reproduces the problem?
|
The iframe where I encountered this is a different domain, so I think it would normally be, but the script I was dealing with uses
Not one that is straightforward (I hit this in a reasonably complex legacy tool I’m now maintaining that deals with Airtable). I’ll try to create a complete test case sometime in the next week or so. |
Yep, if the frame is from a different origin (and probably therefore a separate process), that triggers the bug. Here’s a modified version of your script that works:
And I see this output:
It also doesn’t appear to matter if |
So my current understanding is:
|
Oh, interesting! I thought I had tried this in 11 (I worked my way back from 13 to see when it broke), but I may need to check again. Thanks for helping me understand and clarify the issue! Looking forward to seeing that PR land. 😄 🙏 |
The values for
|
@Mr0grog thanks for double checking. I opened a CL to switch to using content box that should account for paddings/margins/borders properly. |
No problem. Just tried 13.1.1 with that fix, and it’s working great for me — thanks so much! |
Bug description
This is most likely an issue in Chromium, but I figured I’d file here first in case folks here know whether it’s actually intended behavior that Puppeteer needs to deal with or if I’m misunderstanding the issue.
In Puppeteer 12.0.0 (Chromium 97.0.4692.0), the
DOM.getContentQuads
andDOM.getBoxModel
protocol methods (and maybe others) seem to behave differently in headless vs. non-headless mode: in headless mode; they return coordinates relative to the main frame’s viewport (as they used to in both modes), but in non-headless mode, they return coordinates relative to the frame the object they are called with is in.This leads to a situation where
click()
works in headless mode, but not in non-headless mode (because it’s clicking in the wrong place), and where methods likeclickablePoint()
orboundingBox()
return incorrect coordinates in non-headless mode.Steps to reproduce the problem:
Load a page structured like:
Try to get the clickable point of
#inner-content
:Doing the above in headless mode and non-headless mode should log the same coordinate, but does not.
Puppeteer version
12.0.0
Node.js version
16.13.0
npm version
8.1.3
What operating system are you seeing the problem on?
macOS
Relevant log output
No response
The text was updated successfully, but these errors were encountered: