Final Project: Plan, Generate, Heal and Gate
Why This Matters
You have used every part of Selenium AI Agent separately. In a real project they come as one loop: a feature is planned, reviewed, turned into tests, verified, gated in CI, and healed when the application changes, while the guardrails decide what the AI may do alone and what needs you.
This project runs that loop once, end to end, on a feature of the practice site you haven’t tested yet. At the end you have a small suite you can show: approved plan, generated tests, verification, a CI gate, and an audit log that tells the story.
What you will build
A test suite for the checkout form validation of the shop at practiceautomatedtesting.com/shopping, under the guided profile, in Python with pytest. (Prefer Java or WebdriverIO? Lesson 11 shows the differences; everything below works the same.)
| Deliverable | Lesson |
|---|---|
.selenium-agent.json with guided | 16 |
A seed (tests/conftest.py) | 7 |
An approved plan in specs/ with at least one review round | 6, 8 |
| Generated tests, one per scenario | 10 |
| Every test verified | 17 |
| A heal, with the decision documented | 15 |
| A CI workflow with the gate | 18 |
.agent-audit.jsonl with the history | 16 |
Step 1: set up the project
- A new folder with
requirements.txt(selenium,pytest) and a virtual environment. npx selenium-ai-agent doctor: all checks pass (lesson 21).npx selenium-ai-agent init-agents --loop=claude(or your client).- Ask the agent to switch to
guided, in your own words. Check.selenium-agent.jsonand the first audit line. - Write or generate the seed from lesson 7. Register it with
generator_write_seed.
Step 2: plan
Ask the planner for a plan for the checkout form. Name what matters:
Explore the checkout of https://practiceautomatedtesting.com/shopping and write a test plan for the billing form: required fields, invalid email, each payment method and what it shows, and placing an order with test data. Use the seed tests/conftest.py.
Read the plan as a specification (lesson 6’s checklist). Then do at least one review round in the review page: request a change with a comment, let the planner process it, and approve the new version.
Checkpoint: the plan’s status line says approved, and the audit log has the review decisions.
Step 3: generate
Ask the generator to write the tests. For each test, check against its scenario (lesson 10): one check per expect:, the plan’s own values, test data that is obviously fake, the seed’s helpers instead of new driver code.
If generator_write_test refuses a test (a rule, a locator), read the refusal and let the agent fix it. Note the refusals: they are part of your write-up.
Step 4: verify
Verify every test with verify_test_stability (3 runs and the fail check under guided). If a mutant stays green, strengthen the assertion and verify again. If a test is flaky, find the condition it doesn’t wait for; no sleeps, no longer timeouts (lesson 13).
Checkpoint: npx selenium-ai-agent gate passes under guided.
Step 5: heal, and decide
Simulate two changes, one at a time, and handle each:
- A UI change. Edit one test so it uses a selector that doesn’t exist (as if a developer renamed an id). Ask the healer to fix it. Under
guidedit first asks you to confirm your hand edit; then the locator fix goes through. Verify again. - A behaviour change. Edit the plan: change one expected value (for example the text of a validation message) as if the product owner decided so. Run the gate: what does the spec lock say? Then do it the right way: approve the changed plan, regenerate that test, verify it.
Write down, for both, what the agent did on its own and where it needed you.
Step 6: gate in CI
Add the GitHub Actions workflow from lesson 18 with npx selenium-ai-agent gate --run --profile=strict. Push to a branch. Does the gate pass under strict? If not, why not (likely: 3 verification runs where strict wants 5)? Decide: verify with 5 runs, or run CI under guided. Either is fine; write down why.
Step 7: write it up
Half a page, in the project’s README:
- What the suite covers, with a link to the plan.
- How to run it:
pytest -vlocally, the workflow in CI. - The profile and why.
- What the guardrails caught during the project: refusals, a mutant that stayed green, the spec lock. These are the moments the AI would have gone wrong on its own.
- One thing you would set up differently next time.
Assessment checklist
| Done | |
|---|---|
doctor passes; guided is set and in the audit log | ☐ |
| The seed creates one browser per test and uses explicit waits only | ☐ |
| The plan is approved after at least one review round | ☐ |
Every scenario has one test file; every expect: one check | ☐ |
Every test is verified; the gate passes under guided | ☐ |
| The UI change was healed as a locator change | ☐ |
| The behaviour change went through the plan, not through a heal | ☐ |
| CI runs the gate; the profile choice is explained | ☐ |
| The README explains the suite and what the guardrails caught | ☐ |
Show what a good write-up looks like
Checkout validation suite. Plan:
specs/checkout-form.md(approved 2 Dec, one review round: added the invalid-email case). 7 tests intests/checkout/, pytest,guidedprofile locally,strictin CI.Run:
pytest -v(needs Chrome); CI:.github/workflows/e2e.ymlrunsnpx selenium-ai-agent gate --run --profile=strict.What the guardrails caught: the generator’s first version of the iDeal test had a
time.sleep(1)after choosing the bank and was refused (no-sleep); it now waits for the bank list. The empty-form test first asserted only that the first-name field “has a validation message”; its mutant stayed green, so it now compares the exact required-field state. When we changed the expected error text in the plan, the gate flagged all tests from the plan (spec lock), and we regenerated the affected test instead of letting the healer edit it.Profile:
strictin CI needs 5 verification runs; we verified with 5 before merging. Next time: setstabilityRuns: 5inguidedfrom the start so local verification already matches CI.