Closed
Description
cypress-testing-library
version: 2.3.5cypress
version: 3.1.5node
version: 8.15npm
(oryarn
) version: yarn 1.12.3
Note: This issue is related to getByText
, but the problem is in the way it behaves in relation to cypress, not a bug in the actual getByText
function itself.
Relevant code or config
<button disabled>
<span>Hi</span>
</button>
What you did:
cy.getByText('Hi').click()
What happened:
The span element was clicked, even though the button was disabled. The click is ignored by the button though, since it is disabled.
Workaround:
You can revert to normal cypress commands and do this:
cy.contains('button', 'Hi').click();
Cypress will wait until the button is enabled before trying to click. Or if the timeout expires, it will throw an error.
Suggested solution:
I'm not sure? Silently failing seems like the wrong thing though. Perhaps I just shouldn't use cy.getByText
to try to click on a button.
Metadata
Metadata
Assignees
Labels
No labels