SoftwareTestPilot
AI in TestingPublished: 14 min read

AI Testing Tutorial: Build Your First AI-Powered QA Suite in 60 Minutes

A hands-on AI testing tutorial for QA engineers — prompt, generate, run, self-heal and report an end-to-end Playwright suite in one hour using ChatGPT, Claude and Copilot. Includes code, screenshots, PAA FAQs and governance checklist.

Avinash Kamble
Founder & QA Engineer at SoftwareTestPilot
Reviewed by Priyanka G.
Share:XLinkedInWhatsApp
AI testing tutorial cover — laptop with 5-step workflow (Prompt, Generate, Run, Heal, Report), a Playwright browser window and a checkmark badge. SoftwareTestPilot.com wordmark.
AI testing tutorial cover — laptop with 5-step workflow (Prompt, Generate, Run, Heal, Report), a Playwright browser window and a checkmark badge. SoftwareTestPilot.com wordmark.

Last updated: July 15, 2026 · 14 min read · By Avinash Kamble, reviewed by Priyanka G.

This AI testing tutorial takes you from an empty repo to a running, self-healing, AI-generated Playwright suite in about 60 minutes. It consolidates every "AI testing tutorial", "AI in testing tutorial for beginners", "AI-driven testing tutorial" and "how to do AI testing step by step" search into one hands-on walkthrough you can copy-paste.

If you want the theory first, read the LLM for QA testing playbook and AI testing course roadmap. When you're ready to buy a platform instead of building, jump to the AI testing platform buyer's guide.

What you'll build

  • Five Playwright tests generated from a plain-English spec.
  • A self-healing locator loop that recovers from UI drift.
  • An evals harness that grades every AI-generated test against a rubric.
  • A CI job that fails the build on hallucinated selectors.
  • A one-page release report drafted by an LLM and human-reviewed.

1. Prerequisites (5 min)

  • Node 20+, VS Code, and Git.
  • An enterprise LLM key with a no-training clause (OpenAI, Anthropic or Google). Never use consumer chat for real data.
  • GitHub Copilot or Cursor in your IDE.
  • Basic Playwright familiarity — new? Start with our Playwright complete guide.

Bootstrap the project:

npm create playwright@latest ai-tutorial -- --quiet --browser=chromium --ct=false
cd ai-tutorial
npm i -D openai zod dotenv
echo "OPENAI_API_KEY=..." > .env

2. Step 1 — Prompt: write an RCTF spec (10 min)

The single biggest quality lever in this tutorial is the prompt. Use the RCTF framework (Role, Context, Task, Format):

ROLE: You are a senior SDET writing Playwright TypeScript tests.
CONTEXT: The app under test is https://demo.playwright.dev/todomvc.
Users can add, complete, filter and delete todos.
TASK: Generate 5 E2E tests covering: add, complete, delete, filter=Active, clear-completed.
Prefer role-based locators. No hard sleeps. Include one negative case.
FORMAT: Output a single tests/todo.spec.ts file. No prose, no markdown fences.

Paste that into ChatGPT/Claude/Gemini and save the output to tests/todo.spec.ts. Run npx playwright test. Expect 4/5 to pass — the negative case usually needs a tweak.

3. Step 2 — Generate: pair with Copilot in the IDE (10 min)

Open tests/todo.spec.ts. Add a comment: // TODO: cover edit-in-place and Escape-cancel. Accept the Copilot suggestion, run the tests. This is the fastest AI-augmented authoring loop in QA today.

For heavier work (page objects, API layers) use Claude Code or Cursor with the whole repo as context. See our deep dive on GitHub Copilot for testing.

4. Step 3 — Self-heal locators (15 min)

Create src/heal.ts. When a locator fails, dump the DOM, ask the LLM for the nearest role-based selector, and retry once:

import OpenAI from "openai";
const client = new OpenAI();

export async function healLocator(html: string, intent: string) {
  const res = await client.chat.completions.create({
    model: "gpt-5.5",
    messages: [
      { role: "system", content: "Return ONLY a Playwright role-based locator string." },
      { role: "user", content: `Intent: ${intent}\nDOM snippet:\n${html.slice(0, 4000)}` },
    ],
    temperature: 0,
  });
  return res.choices[0].message.content?.trim();
}

Wrap your page.locator() calls in a try/catch that invokes healLocator on failure. Log every heal event so a human can review. Ship the healed selector to Git as a PR — never overwrite silently.

5. Step 4 — Evals: grade the AI (10 min)

Add evals/rubric.ts — score every AI-generated test on the 7-point rubric:

  1. Compiles without edits
  2. Uses role-based locators only
  3. No hard sleeps
  4. One assertion per behaviour
  5. Independent (can run in any order)
  6. Deterministic seed data
  7. Fails loudly (no swallowed errors)

Run the rubric in CI. If any test scores below 5/7, block the merge and open a review issue. This is how you keep hallucinations out of main.

6. Step 5 — LLM-drafted release report (5 min)

After the suite runs, feed the JUnit XML and heal-log into a prompt that returns a one-page release brief (pass rate, top 3 flakes, healed locators, risk call). See templates in 40 AI prompts for testers.

7. Wire it into CI

name: ai-tests
on: [pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 20 }
      - run: npm ci
      - run: npx playwright install --with-deps chromium
      - run: npx playwright test
        env:
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
      - run: node evals/run.js

Related: GitHub Actions CI for automation.

8. Governance checklist

Every AI-in-testing engagement must run under governance:

  • Enterprise LLM APIs with a no-training / zero-retention clause. Never paste customer data into a free consumer chat.
  • Redact PII, PANs, JWTs, HARs, secrets and production URLs before any prompt.
  • Version prompts, evals and agent tools in Git. Every AI-generated artefact ships with an AI-attribution line and a named human reviewer.
  • Map controls to the NIST AI RMF and, for EU products, the EU AI Act.

Frequently asked questions

1.What is an AI testing tutorial?
A step-by-step, hands-on walkthrough that shows a QA engineer how to use LLMs and code assistants to design, generate, execute, self-heal and report software tests. Unlike a broader AI testing course, a tutorial focuses on one runnable project you can finish in a single sitting.
2.How long does this AI testing tutorial take?
About 60 minutes end-to-end if you already have Node, Playwright and an LLM API key. First-timers should budget 90 minutes to install prerequisites and register for a Copilot or LLM key.
3.Do I need to know Playwright to follow this AI testing tutorial?
Helpful but not required. Every command is copy-paste. If terms like fixture, locator or trace are new, keep the Playwright docs open in a second tab or read our Playwright complete guide first.
4.Which AI model should I use for this tutorial?
Any modern frontier model works: OpenAI GPT-5.5, Anthropic Claude 3.7/4 or Google Gemini 2.5 Pro. Use an enterprise API key with a no-training clause. Never paste real customer data into a consumer chat window.
5.Is it safe to let AI heal my Playwright locators automatically?
Yes if you log every heal event, ship the fix as a pull request, and require human review. Do not overwrite the failing selector silently in main — that is how you accumulate invisible test drift.
6.How do I stop the AI from writing tests that always pass?
Grade every AI-generated test against a rubric (compiles, role-based locators, no hard sleeps, one assertion per behaviour, independent, deterministic data, fails loudly). Block the PR if any test scores below 5/7.
7.Can I use ChatGPT free tier for this tutorial?
Yes for the prompt-and-generate steps against public demo apps like todomvc. For any real product or customer data, upgrade to an enterprise plan with zero data retention. See the governance section.
8.How does an AI testing tutorial differ from an AI testing course?
A tutorial produces one working artefact in an hour. A course covers curriculum: LLM basics, prompt engineering, evals, agentic testing, governance and portfolio projects over 30–60 days. Do the tutorial first for momentum, then follow the course roadmap.
9.What if the AI hallucinates a selector or an API endpoint?
The evals harness catches most of it: the test either fails to compile, fails to find the locator, or asserts something that never existed. Add a smoke test that hits every generated selector on the real DOM before merge.
10.Can I do this AI testing tutorial for API tests instead of UI?
Yes. Swap Playwright for Supertest or Postman and feed the LLM your OpenAPI spec. See our companion pillar on generative AI API testing for the full walkthrough.
11.Does this AI testing tutorial work for mobile apps?
The prompt-generate-heal-evals loop is identical; swap Playwright for Appium and record page source (XML) instead of DOM. See the mobile section of the AI testing platform pillar.
12.What's the next step after finishing this tutorial?
Pick one repetitive QA task at work — regression selection, bug drafting or test-data generation — automate it end-to-end with AI, measure hours saved and present it in your next sprint review. That project becomes your interview story.
Keep going

Practice these questions

Run a live QA mock interview tailored to this topic and get per-skill scoring in minutes.

Found this useful?
Share:XLinkedInWhatsApp

Was this article helpful?

Cluster · AI in Testing

More from AI Testing Tools

Testim, Mabl, Functionize, self-healing platforms.

Pillar guide · 8 articles
More in this cluster
From the AI in Testing pillar

Keep building your QA edge

Continue reading

Join the QA Community

Connect with fellow testers, share job leads, and get career advice.

Premium QA Resources

Stop Reinventing the Wheel. Upgrade Your QA Arsenal.

Take your testing skills from beginner to Lead Engineer. Supercharge your daily workflow with our premium digital resources.

  • Ready-to-use testing strategy templates
  • Advanced API & UI automation guides
  • ⏱️ Save 10+ hours a week on test planning
4.9/5 rating
Explore All Products

⭐⭐⭐⭐⭐ Trusted by 1,000+ Software Test Pilots • Instant Access