'I can't get id or data-test in cypress recently
I'm trying to get a button with [data-test=ex_button]
and click on it in cypress with using the following code:
cy.get('[data-test=ex_button]').click({ force: true })
and my UI code:
<el-button
data-test="ex_button"
type="primary"
class="button-flat pull-right"
@click="myFunction">
{{ tr('myButtonName') }}
</el-button>
But Cypress fails with the following error message:
Timed out retrying: Expected to find element: [data-test=ex_button], but never found it.
and when i want to open selector playground cy.get()
for check it i never found it.
Solution 1:[1]
You should use data-test-id
attribute instead
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Dmitrii V |