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
Use try catch to protect querySelector #12734
Conversation
try { | ||
found = scopedQuerySelector(context, selector); | ||
} catch (e) { | ||
user().error(TAG, 'Invalid query selector :', selector, e); |
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.
We also throw user error when can't find target element. I figure invalid selector is somehow different from that error.
Let me know if two errors "invalid selector" + "element not found" are not wanted..
8b51e4c
to
7083d9b
Compare
if (found && this.contains(found)) { | ||
result = found; | ||
} | ||
return user().assertElement( |
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.
we can move this to be after the catch block to avoid doubling the error messages.
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.
done
* use try catch to protect querySelector * only send one error * reorder
* use try catch to protect querySelector * only send one error * reorder
closes #12563