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
waitForSelector with visible:true not returning the first visible element, causes timeout. #4356
Comments
A working solution (though, not ideal) is as follows. Ideally the waitForSelector with { visible:true } would behave this way... or the documentation clearly states that it doesn't do this.
|
Sounds reasonable. PRs welcome. |
This patch fixes an issue where waitForSelector with visible:true would cause a timeout should there be multiple elements matching the selector, but the ones higher up on the DOM are hidden. It now returns the first visible element it finds. fixes puppeteer#4356
This patch fixes an issue where waitForSelector with visible:true would cause a timeout should there be multiple elements matching the selector, but the ones higher up on the DOM are hidden. It now returns the first visible element it finds. fixes puppeteer#4356
@JoelEinbinder PR is up, though you guys don't have any info or docs on testing/building for the experimental/firefox stuff. what's the protocol? |
@razorman8669 Ok I see what you mean here. Indeed, the behavior is somewhat confusing. However, I disagree with the proposed approach. CSS selector is the only thing that we should use to identify the element. Adding the suggested logic adds magic to how we find elements - making it equally hard to debug. The best solution here is to update the documentation - so that we do a better job explaining what's going on. |
So , since razorman's fix did not go through. What is the alternative if I hit this case ? I do wish to skip the first selector ( inside display none) and assert on the second selector like the bug explains. Any alternatives or suggestions ? |
Hey, @aslushnikov is this task up for grab? I would like to kickstart my contribution and looking for a good first issue. Also, I completely agree with you as technologies like selenium also moving towards finding element through CSS selector components only and giving consistent behaviour across technologies should be an ideal thing to do. |
I'm having this same issue. For most instances of the element in question, parent elements are hidden, and I need the visible elements matching the selector. How are we supposed to find the 1 (or more) visible element among many hidden elements with the same selector? |
Hi Guys, I would like to help and contribute to the repo. Is this bug still up for grabs ?. I am actually new to open source contribution, so is there any way I can kickstart my contributions. Would like your help here. |
Similar situation that I think is being caused by the same bug. I would like to use a |
Any updates on this? What should be the recommended approach in this case? |
You can do: await page.waitForSelector('.my-input-class |
We're marking this issue as unconfirmed because it has not had recent activity and we weren't able to confirm it yet. It will be closed if no further activity occurs within the next 30 days. |
It's been confirmed repeatedly. Don't know who "we" is in a bot's language. |
We're marking this issue as unconfirmed because it has not had recent activity and we weren't able to confirm it yet. It will be closed if no further activity occurs within the next 30 days. |
It's been confirmed repeatedly. Don't know who "we" is in a bot's language. |
I don't think we are not going to support the feature request in the near future. As pointed out in #4356 (comment), the web APIs don't offer a way to query only the visible tree of elements and we should not change the semantic of CSS selectors. The workarounds are 1) use selectors that identify the visible element uniquely or 2) implement retries + waiting heuristics for becoming visible that are specific to your use case. Perhaps we should change the API to be |
Steps to reproduce
Tell us about your environment:
What steps will reproduce the problem?
Open Website OR use this file:
Please include code that reproduces the issue.
What is the expected result?
There are 2 elements matching the CSS Selector on the page. the first one is hidden, the second one is visible. The
page.waitForSelector
with{visible: true}
should have found and returned the visible element on the page.What happens instead?
It Times Out since there was another HIDDEN element matching the CSS selector higher up in the DOM structure, causing it to wait until timeout even though a visible element exists on the page.
The text was updated successfully, but these errors were encountered: