Skip to content
Course outline

Lab: automation code from real locators

Get automation code for Cedar Books pages from QAIA, then read its locators like a reviewer: which will last?

  • 30 minutes
  • With QAIA
  • 2 planted bugs
  • Needs a QAIA account

Automation code is only as stable as its locators: the way it finds each button and field. A test that finds a button by its position breaks with the next design change; one that finds it by its role and name survives.

In this lab QAIA writes Playwright and Selenium code for two Cedar Books pages from the elements it really found there, and you review the locators it chose and what each page logged.

Open Cedar Books Its requirements

What you need

  • A QAIA account, signed in.
  • Optional: Node.js and Playwright on your computer, to run the code (npm init playwright@latest).
  • The lesson on testing tools, if Playwright and Selenium are new to you.

Steps

  1. In QAIA, run a single-page analysis (QAIA Foundation or QAIA Swift) of the shop's home page, https://practice.qaia.io, with Console log capture turned on.
  2. Open the Locators tab. For three elements (the search box, the Basket button, and the basket button on one book card), compare the id, test id, role, CSS and XPath QAIA found.
  3. Open the Playwright tab and read the generated code. Which locators did it use, and why? Use Custom generation to get the same code in another language, or as Selenium code.
  4. Run a second single-page analysis, of https://practice.qaia.io/books/28 (The Island With One Tree), again with Console log capture turned on, and read its console tab.
  5. Optional: run the Playwright code on your computer and watch it pass or fail.
  6. Write down every element that had no good locator and every error a page logged, and why each matters. Then sign in here and press "Check my QAIA run".

Hints

Stuck? Open one hint at a time, and try again after each one.

Hint 1

Test ids and role-plus-name locators survive design changes best; long XPath chains break first.

Hint 2

An element with no name is hard to find for a test and for a screen reader alike: the same fix helps both.

Hint 3

NFR-04 asks for no JavaScript errors during normal use. A page with nothing to show in one of its parts is still normal use.

Done? Record it

This lab is done with QAIA, so it needs a QAIA account. Sign in, finish the run, then come back here to record it.

Sign inRequest accessStart freeGet started

Finished it in QAIA? The Academy looks for your own finished run, and reads only that it happened. What counts: A finished single-page analysis (QAIA Foundation or Swift) of a page on https://practice.qaia.io.

The planted bugs

This lab is about 2 of the shop's planted bugs. Compare your notes with the planted bugs of this lab below: one makes automation harder, and one only shows in the console.

Sign in to see the planted bugs this lab is about. They are kept off this page, so nobody reads them by accident before trying.

Sign inRequest accessStart freeGet started

Try the lab before you look: a bug you find yourself teaches far more than one you read about.

Learn the skill

Put the lessons to work on a real site

Describe a user journey in plain English. QAIA walks it in a real browser and hands back the test cases, the automation code and the evidence of every step.