Skip to content

A full user flow

Chapter lab: Forms and flowsch09-web-flows.zip · 27 KB

This lesson continues in the same lab as the lesson before it. If you don’t have it yet, download it here.

Download ch09-web-flows.zip

Or fetch and unpack it from a terminal in VS Code:

Terminal window
curl -fsSLO https://manykarim.github.io/robotframework-essentials-web/labs/ch09-web-flows.zip && unzip -q ch09-web-flows.zip && rm ch09-web-flows.zip

Open the folder in VS Code with code rfe-ch09-web-flows (or File → Open Folder…) and accept the recommended RobotCode and Python extensions. Then set it up:

Terminal window
uv sync
Terminal window
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Keep the environment active in every terminal where you run lesson commands.

Terminal window
poetry install --no-root

Python 3.13 or newer is required; uv installs it when it is missing.

Also needed for this lab

Install Node.js (an LTS release), then run once — it downloads a browser engine (large):

Terminal window
uv run rfbrowser init chromium
Terminal window
rfbrowser init chromium
Terminal window
poetry run rfbrowser init chromium

Start the RF Demo Shop in its own terminal and keep it running while you work:

Terminal window
uv run python demo_app/serve.py
Terminal window
python demo_app/serve.py
Terminal window
poetry run python demo_app/serve.py
What's inside
  • Directoryrfe-ch09-web-flows/
    • Directory.vscode/
      • extensions.json
    • Directorychecks/
      • smoke.robot
    • Directorydemo_app/
      • api.py
      • serve.py
      • store.py
      • web.py
    • Directoryresources/
      • shop.resource
    • .gitignore
    • .python-version
    • LAB.md
    • pyproject.toml
    • README.md
    • requirements.txt
    • uv.lock

Now put it together: one customer, one journey — sign in, add an item, check out, and confirm the order. This is the test you tag as your smoke test later, because when it is green the core of the shop works.

Task 1 — Drive sign-in → cart → checkout → confirmation

Section titled “Task 1 — Drive sign-in → cart → checkout → confirmation”
Edit

Goal: create checks/flow.robot that signs in, adds a product, goes to checkout, fills the form, places the order, and asserts it reads complete.

Here is the same journey for a different customer buying a different product. Adapt it to primary_user adding the travel mug.

Worked example — adapt it, don’t copy it

*** Settings ***
Library Browser
Resource ../resources/shop.resource
*** Test Cases ***
Reviewer Buys A Backpack
New Browser chromium headless=True
New Context
New Page ${BASE_URL}/login
Fill Text data-testid=login-username reviewer_user
Fill Text data-testid=login-password learning-password
Click data-testid=login-submit
Click data-testid=add-trail-backpack
Get Text data-testid=cart-heading contains Cart
Click data-testid=go-checkout
Fill Text data-testid=checkout-first Grace
Fill Text data-testid=checkout-last Hopper
Click data-testid=place-order
Get Text data-testid=order-status == complete
Close Browser

Done when

the suite defines Customer Completes A Purchase.

Hint 1

After signing in, add the mug with Click data-testid=add-travel-mug, then confirm the cart with Get Text data-testid=cart-heading contains Cart.

Hint 2

Go to checkout, fill checkout-first and checkout-last, Click data-testid=place-order, then assert Get Text data-testid=order-status == complete.

Solution
*** Settings ***
Library Browser
Resource ../resources/shop.resource
*** Test Cases ***
Customer Completes A Purchase
New Browser chromium headless=True
New Context
New Page ${BASE_URL}/login
Fill Text data-testid=login-username primary_user
Fill Text data-testid=login-password learning-password
Click data-testid=login-submit
Click data-testid=add-travel-mug
Get Text data-testid=cart-heading contains Cart
Click data-testid=go-checkout
Fill Text data-testid=checkout-first Ada
Fill Text data-testid=checkout-last Lovelace
Click data-testid=place-order
Get Text data-testid=order-status == complete
Close Browser
Run

Run:

Terminal window
uv run robot checks
Terminal window
robot checks
Terminal window
poetry run robot checks

Done when

the purchase journey ends with order-status reading complete.

Check your understanding

Quick recall. Your first answer stays in this browser; the quiz never blocks your progress.

  1. A good end-to-end test…

    Show the answer

    Answer: follows one real user journey and asserts the outcome — An end-to-end test walks a real journey — sign in, add to cart, check out — and asserts the final confirmation.

  2. After placing the order, what confirms success?

    Show the answer

    Answer: order-status reads complete — The order page shows order-status = complete once the purchase goes through.

Key terms

end-to-end flowconcept
One user journey asserted from start to confirmation — tag it as your smoke test.

All terms in the glossary →