Stop 13 · AI & Modern QA PracticesTopics · 2/7

AI-Assisted Test Automation

Part of the QA Testing Roadmap

In short

AI coding assistants can turn 'test that a wrong password shows an error' into runnable Playwright code in seconds. The catch: they often pick brittle locators and weak assertions unless you steer them.

Using AI to help write or maintain automation scripts — generating boilerplate code, suggesting locators, or converting a plain-language test scenario into runnable automation code.

The purple blob in a chef's hat tastes curry while a small robot chops vegetables beside it.

Think of it like this

Head chef with a fast helper

A helper chops onions and tomatoes at lightning speed, which saves the head chef an hour. But the head chef still tastes the curry and decides the spice. AI writes the boilerplate; you decide if the test is any good.

Watch it happen

Pairing with an AI coding assistant

You
Assistant
Test run

wrong password test

1/5You describe the scenario in plain English, plus a link to your page object or an existing test as an example.

The big ideas

What you need to know

Boilerplate is free now

Setup, imports, page objects and repetitive steps are where AI saves the most time.

Check the locators

Prefer role, label and test-id locators. AI often reaches for long CSS paths that break on redesign.

Check the assertions

A test without a meaningful assertion only proves the page didn't crash. Make sure it checks the actual result.

You own the code

If you can't explain every line, you can't fix it when it fails at 2 a.m. in CI.

See it in code

Walk through the code

ts
1// AI draft: works today, breaks on the next redesign2await page.locator("div.form > input:nth-child(2)").fill("wrong-pass");3await page.locator(".btn-primary").click();4 5// After your review: user-facing locators and a real assertion6await page.getByLabel("Password").fill("wrong-pass");7await page.getByRole("button", { name: "Log in" }).click();8await expect(page.getByRole("alert")).toHaveText("Incorrect password");

1/3Position-based CSS and a styling class. Move one field or rename a class and it breaks.

Same scenario, two versions. The reviewed one survives layout changes and actually checks the outcome.

Save yourself the pain

Common mistakes

Oops

Accepting a generated test because it passed once.

Do this instead

Make it fail on purpose too. A test that can't fail is useless.

Oops

Letting the assistant invent locators for a page it has never seen.

Do this instead

Give it the real HTML, a page object, or use Playwright's codegen to record real locators first.

Your mission

Steer the assistant

~35 min

Quick check

An AI-generated test clicks the login button and then ends. What's wrong with it?

Go deeper

  1. 1Use an AI coding tool to draft a simple automation script from a plain-language description.
  2. 2Compare the AI-generated script against your own Phase 7 automation skills.
  3. 3Learn to review AI-generated automation code critically before trusting it in a real suite.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge