Reputation: 211
I'm new to nightwatch.js. I work in QA and the developers don't want to use ids or classes for the automated tests. They want to use data-test
. So for example data-test="nav-button"
.
Is there way to find elements and click elements using this attribute in nightwatch.js?
Upvotes: 5
Views: 2836
Reputation: 479
This is actually pretty simple. Just put the data-test
in square brackets after the element type. See below for examples. In these examples, the data-test attribute is in an anchor tag.
.waitForElementVisible('a[data-test=nav-button]')
.click(a[data-test=nav-button])
Upvotes: 5