Employing selectors and assertions
Selectors are identifiers for elements in the Document Object Model (DOM). We have various ways to identify elements, such as using their class, name, type, and so on. Every test framework has its own custom commands to make the code clear and concise. Cypress provides users with an efficient interface to look for selectors and comes with standard support for all selectors. Let us continue using our first spec to dig deeper into utilizing selectors.
Working with selectors
cy.get is the primary function to search for elements in the DOM. In our search_title.cy.js test file, we have used .input-text, which identifies the element with the input-text class name and sets a value in it. We have also used [aria-label="Search"] to look for the Search button. This is an example of an attribute search. We are essentially finding an element with the value of the aria-label Search attribute and clicking on it. id and data are other reliable attributes...