Explore the Shop with the Planner
Why This Matters
Most automated tests that fail for no good reason were written from memory: a tester remembered how the page worked, a developer guessed a selector, an AI filled in what a shop “usually” looks like. The planner works the other way round. It opens the real application, looks at what is there, and writes down only what it saw: the real labels, the real button texts, the real test ids, the real prices.
The result is a test plan: a Markdown file that says what to test, step by step, with the expected result after every step. It is the most important file in this course. Everything after it (the tests, the reports, the healing, the CI gate) is checked against it.
What you will learn
- What the planner does, tool by tool
- How to ask for a plan, and what a good request contains
- How a plan is structured: suites, tests, steps, expectations, elements and gaps
- How to read a plan critically before you approve it (lesson 8)
The planner in three tools
The selenium-test-planner agent (installed with init-agents in lesson 2) uses ordinary browser tools to click around, plus three planning tools:
| Tool | What it does |
|---|---|
planner_setup_page | Starts the session: opens the application, runs optional setup steps (such as a login) and loads the seed test the generated tests will follow (lesson 7). Called once. |
planner_explore_page | Takes an inventory of a page: headings, fields with their labels and test ids, dropdown options, buttons (including disabled ones), links and forms. |
planner_save_plan | Saves the plan to specs/<name>.md in a fixed layout, as a draft. |
Between those calls the agent uses the tools from lesson 3: capture_page to get element refs, click_element and input_text to try a flow, verify_text_visible to confirm what it sees.
Ask for a plan
A good request names the application, the feature and what matters to you:
Use the selenium-test-planner agent to explore https://practiceautomatedtesting.com/shopping and write a test plan for adding products to the cart and checking out. Include the totals and VAT, one payment method, and what happens with an out-of-stock product. Leave search and filters out for now.
Three things make this a good request:
- One feature, not the whole site. A plan for “the shop” becomes either huge or shallow. A plan per feature stays reviewable.
- What matters is said out loud. The totals and VAT are where the money is; the out-of-stock product is a business rule. The planner would not know that on its own.
- What is out of scope is said too. Otherwise the plan grows sideways.
What the planner does
The agent starts with planner_setup_page:
{
"url": "https://practiceautomatedtesting.com/shopping",
"feature": "Shopping cart and checkout",
"explorationDepth": "single_page"
}
explorationDepth tells it how far to look: quick, single_page, section or full_site. For one feature on one page, single_page is enough.
Then it explores. It reads the inventory with planner_explore_page, adds a product with click_element, opens the cart, looks at the checkout form, tries each payment method, and clicks the out-of-stock product to see what happens. The planner agent’s instructions are explicit about this: base every step on what you saw, with real labels, real button texts and real test ids.
The plan
The planner saves the plan with planner_save_plan. You give it structure, and the tool writes the Markdown, so every plan has the same layout. This is the plan the planner wrote for the shop (shortened; the full plan has eight tests):
# Shopping cart and checkout
**Status:** draft — review this plan, then change "draft" to "approved" here (or tell the agent you approve it). Tests are only generated from an approved plan.
## Application Overview
The shop at practiceautomatedtesting.com/shopping lists 10 products in 4 categories, 6 per page.
Products are added to the cart from the product grid or from a product detail pop-up. The cart
button shows the item count and running total and opens the checkout pop-up: billing details,
payment method (Credit Card, PayPal or iDeal) and an order summary with free shipping and 21% VAT.
No login is needed; the cart is empty on every page load.
## Elements
| Element | Locator |
|---|---|
| Search field | `[data-testid="search-input"]` |
| Add to Cart in the grid (per product id) | `[data-testid="add-to-cart-<id>"]` |
| Cart button (count and total) | `[data-testid="cart-button"]` |
| Place Order / close checkout | `[data-testid="place-order"] / [data-testid="close-checkout"]` |
## Test Scenarios
### 1. Add to cart
#### 1.1. Add a product from the grid
**File:** `tests/cart/test_add_from_grid.py`
**Steps:**
1. Open the shop
- expect: The heading shows "Search Results (10 products)"
- expect: The cart button shows "0 items" and "$0.00"
2. Click "Add to Cart" for the Mechanical Keyboard
- expect: The cart button shows "1 items"
- expect: The cart total is "$89.99"
#### 1.3. Out-of-stock product cannot be added
**File:** `tests/cart/test_out_of_stock.py`
**Steps:**
1. Find the HD Monitor in the grid
- expect: Its button reads "Out of Stock" and is disabled
2. Try to click the button
- expect: The cart still shows "0 items"
### 2. Checkout
#### 2.1. Totals for two products
**File:** `tests/checkout/test_totals_two_products.py`
**Steps:**
1. Add the Mechanical Keyboard and the Ergonomic Chair
- expect: The cart button shows "2 items" and "$289.98"
2. Open the cart
- expect: Subtotal $289.98
- expect: Shipping FREE
- expect: Tax (21%) $60.90
- expect: Total $350.88
## Gaps and Questions
- The page's own test scenarios mention quantity +/- buttons, a Remove button, "Continue Shopping",
"Proceed to Checkout" and a "Your cart is empty" message. The cart button opens the checkout
directly, so there is no cart view with these features. To clarify with the product owner.
- The price sliders have no visible label; tests can only use their test ids
(min-price-slider, max-price-slider).
How to read a plan
Every part of the plan has a job.
Status. Every new plan is a draft. The generator refuses to write tests from it until a person approves it (guardrail 1 from lesson 4, and the subject of lesson 8).
Application Overview. What the planner understood the feature to be. If this paragraph is wrong, everything below it is wrong too. Here it says something important for the tests: the cart is empty on every page load. That is why every test can start from “0 items”.
Elements. The locators the planner found, test ids first. The generator uses these instead of inventing its own, and under the strict profile they become locked locators (lesson 12).
Tests. One #### heading per test, each with:
- a File: where the generated test will be saved. One plan test becomes one test file, and the report links every result back to it (lesson 14).
- Steps, each with one action and one or more
expect:lines. Eachexpect:becomes one assertion, placed right after the step it belongs to.
Gaps and Questions. This is where a good planner earns its keep. The shop page itself lists test ideas (a Remove button, quantity buttons, “Your cart is empty”) that the application does not have. The planner did not write tests for features that don’t exist; it wrote them down as a question for a person.
What a good plan looks like
Check the plan against these points before you approve it:
| Check | In the shop plan |
|---|---|
Every step that changes something has an expect: | Yes: every click is followed by what the cart shows |
| Expected values are concrete | “$289.98”, “Tax (21%) $60.90”, not “the total is correct” |
| Tests are independent | Each starts from an empty cart; none relies on another |
| Negative cases are included | Out-of-stock product, Place Order with empty fields |
| Nothing is invented | Features the page doesn’t have are in Gaps, not in tests |
| Locators are stable | Test ids, not positions or classes |
And one check only you can do: are the expected values right? The planner wrote down what the shop shows. If the shop calculates VAT wrongly, the plan now says the wrong amount is correct. 21% of $289.98 is $60.8958, so $60.90 is right. Do that sum yourself before approving; the AI copied it from the screen.
Exercise
Ask the planner for a plan for search and filters on the shop page (the part we left out). Before you look at the suggested answer, read the plan the planner gives you and answer:
- How many tests did it write, and which
expect:lines are vague? - Does it test a combination of filters, or only one filter at a time?
- What did it put under Gaps and Questions?
Show suggested answer
Plans differ per run, but a good search-and-filters plan:
- Has around six to ten tests: search for a word, search with no results, each filter type (category, rating, in stock, on sale, price range), sorting, and “Clear All Filters”. A vague
expect:says “the results are filtered”; a concrete one says “Search Results (2 products)” and names the products. - Includes at least one combination (for example category Electronics plus In Stock Only), because filter logic breaks in combinations, not in single filters.
- Mentions the price sliders without a visible label, and anything the page’s own scenario list describes that the application does not do (such as an “active filter count badge”, if it is not there).
If the plan has none of these, ask the planner to add them: “Add a test for combined filters and one for a search with no results.” That is the normal way to work: the first plan is a draft for a reason.
Exam-style questions
1. Where does the planner get the expected values in a plan from?
- A. From the requirements documents only
- B. From what it saw in the running application
- C. From common patterns in similar web shops
- D. From the generated tests
Show answer
2. The shop page lists “Test the Remove button” as a test idea, but the application has no Remove button. What should the planner do?
- A. Write a test that expects the Remove button
- B. Leave it out silently
- C. Put it under Gaps and Questions for a person to clarify
- D. Add a Remove button to the application
Show answer
3. What does one expect: line in a plan become in the generated test?
- A. A comment
- B. One assertion, right after the step it belongs to
- C. A separate test
- D. A wait of 5 seconds