lecture 3 of 190 completed

Locator policy, and finding the right one of many

A list can change its order at any time. Find the item by what stays with it, check the result by name, and make a tool and a reviewer enforce it.

What you'll learn

  • Why .first() and cy.contains can act on the wrong item, and how to find the right one by name
  • Why a check by count cannot tell one product from another
  • How to write a selector policy and enforce it with a lint rule and review

Orchard Books is an invented bookshop. Here is a test from its suite. It has passed every day for a year:

full course

Keep reading with the full course

The Foundations track and the first lessons in each framework are free. This lesson needs full course access. A course plan includes all lessons for Playwright, Cypress and Selenium.

See course plans →