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
fix(frame): Fix Frame.waitFor's XPath pattern detection #5184
fix(frame): Fix Frame.waitFor's XPath pattern detection #5184
Conversation
Up to now, only strings starting with '//' are considered as to XPath selectors. Unfortunately, this is too restricting. This fix allows valid XPath selectors starting with: '/', './', and even '(//*[1])'
This needs tests. |
It's my first PR here. Never done any test for this before. |
Look for the existing |
This patch allows to wait for and select an element with a parenthesis-starting xpath. Before this, only double slashes starting xpath were allowed.
Ok thanks. I've changed the xPathPattern to allow for the use of XPath starting with not only "//" but also with an opening parenthesis. In my last commit, I've also added a new test accordingly. |
03a4ca1
to
d4b17bd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xprudhomme Thanks for your contribution! Please resolve the merge conflicts and I'm happy to get this landed!
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
@googlebot I consent. |
Up to now, only strings starting with '
//
' are considered as to XPath selectors.Unfortunately, this is too restricting and leads to errors especially when asking the page to wait for XPath selectors not starting with '
//
'.If the XPath is something like '
(//div)[4]/@itemprop
' then it is passed to the waitForSelector method and eventually document.querySelector, which in turn throws an error because it does not recognize it as a valid CSS selector.Because of this, I had to implement something like this in my code:
This fix allows the use of valid XPath selectors starting with parenthesis and to be recognized as such by the Frame's waitFor method.