You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
getByRole can't find the element. But it works if I use getByText like that:
screen.getByText(/button/i)
Is this the expected behavior? And why?
The text was updated successfully, but these errors were encountered:
felipecesr
changed the title
Shouldn't ByRole query find an element with display: none if I'm using hidden: true?
Shouldn't ByRole query find an element with display: none if I'm using hidden: true?
Aug 13, 2024
Hi @felipecesr, thanks for opening this.
As you can see in the output of the test, hidden attributes have no accessible name:
Here are the available roles:
button:
Name "":
<button
style="display: none;"
/>
This is following the spec, the problem is browsers sometimes don't follow the spec and that's why you can see an accessible name in Chrome for example.
I'm closing this as works by design since we're spec compliant here.
I want to get an element with
display: none
style using the bellow query:getByRole
can't find the element. But it works if I usegetByText
like that:Is this the expected behavior? And why?
The text was updated successfully, but these errors were encountered: