LAB 16 OF 31

CSS or XPath: pick the stable locator

Choose the locator that will still work after the page changes.

The diagram

Mei needs to find the Save button on the Add task form. The button is <button data-test="save-task" class="btn btn-blue btn-lg">Save</button>. Pick the best locator at each step.

  1. Which locator is best for the Save button?
  2. A restyle renames the classes. Which locator breaks?
  3. The team adds a Cancel button before Save. Which locator breaks?
  4. There is no test attribute. Which is the next best choice?

0 of 4 steps chosen.

SYNTHETIC / TRAINING ONLY. The Daily List app and the people in it are made up, and every number is a teaching figure.

What this shows

A stable locator uses a test attribute or a clear role, not a position or a long path.

Read the lessons

NEXT LAB: REGEX: MATCH THE INPUT →