Overview - Best practices for selectors
What is it?
Selectors are ways to find elements on a web page for testing. They tell Cypress exactly which button, input, or text to interact with. Using good selectors means tests are reliable and easy to maintain. Bad selectors can break tests when the page changes.
Why it matters
Without good selectors, tests fail often and need constant fixing. This wastes time and causes frustration. Good selectors make tests stable and trustworthy, so developers can focus on building features, not fixing tests. They also help tests run faster and clearer.
Where it fits
Before learning selectors, you should know basic HTML structure and CSS selectors. After mastering selectors, you can learn advanced Cypress commands and test design patterns. Selectors are a foundation for writing any automated UI test.