-
Notifications
You must be signed in to change notification settings - Fork 2
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
Allow passing a Page instead of an ElementHandle to getAccessibilityTree #344
Conversation
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.
This code looks good to me and it makes sense to have a quick way to grab the body.
I'm less clear on the use case of queryEl.container
. In the examples you documented this variable is always matching an existing variable. Could you share more context for when you'd need this? It might be nice to add that context to the docs.
Make getAccessibilityTree default to the document if no element is passed
This alternative solution makes a lot of sense to me!
Me too 😂 . I mostly put it there so that it parallels the Here is a somewhat contrived use case:
Since the
Yeah I think this solution probably is better. I'll implement that and we can talk about removing |
Sounds good 👍 If we end up leaving in |
@Paul-Hebert I took out screen.container. Maybe we can re-add it if we have a good use case for it. Now getAccessibilityTree accepts a Page as the first parameter, and if that is passed it will print the accessibility snapshot of the entire document (from the |
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.
LGTM!
Overview
After using
getAccessibilityTree
a bit I realized that it is very common to want to dogetAccessibilityTree
on the whole document, so I made a shortcut to get a reference to the body element:This is equivalent to:
Also, it can be used to get a reference to the container element used after calling
within(el)
to get queries scoped to a specific element:In this example,
container
andel
are bothElementHandle
s that point to the same element.Alternate solutions
.container
root
el
element
getAccessibilityTree
default to the document if no element is passedwithBrowser
callbackI don't know which of these solutions would be best (it is also possible to implement multiple of them). Let me know if y'all have thoughts on which would be best, it would be pretty easy to implement any of them.