Best Practices
This guide aims to share our best practices that help you write performant and resilient tests.
Use resilient selectors
Using selectors that are resilient to changes in the DOM, you'll have a less or even no tests failing when the for example a class is removed from an element.
Classes can be applied to multiple elements and should be avoided if possible unless you deliberately want to fetch all elements with that class.
// 👎
await $('.button');
All these selectors should return a single element.
// 👍
await $('aria/Submit');
await $('[test-id="submit-button"]');
await $('#submit-button');