Selenium reports: an HTML report and a screenshot when a test fails
Turn pytest runs into a easy-to-share HTML report, take a screenshot when a Selenium test fails, and attach both so a failure can be understood without a re-run.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: a flight recorder and a photo of the dials. After a bad landing, investigators read the recorder and look at a photo from that moment. They do not fly the route again just to see the dials.
Tom retains evidence from a synthetic Selenium/pytest run. An is generated here by pytest-html. A failure screenshot records visible browser state captured before teardown. A changes how report resources are packaged; it does not automatically embed every externally linked image.
The flight-recorder picture helps preserve a particular run, not reconstruct every server event. A report, its image attachment and the observed failure are separate pieces of evidence.
The picture has a limit. Capture can fail, setup or teardown can fail without a normal test-call failure, and an image can show sensitive data. Preserve the original failure even when extra evidence is unavailable.
(SYNTHETIC / TRAINING ONLY: Daily List and every named person are invented.)
PLAIN WORDS · 5 in this section
- selenium
- A free tool that drives a web browser for checks.
- pytest
- A free Python tool that finds and runs checks.
- teardown
- The tidy-up step that runs after a check.
- embed
- build in as part of something else
- reconstruct
- piece together or rebuild from evidence
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.
THE REAL JOB Retain the actual test failure and relevant browser evidence in a deliberately delivered report.
- Recorder
- Photo
- Envelope
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| The recorder summary | The HTML test report |
| A photo of the dials at that moment | The screenshot on failure |
| A sealed envelope | The self-contained report |
| An investigator | The reader of the report |
WHERE THIS PICTURE STOPS
- A screenshot is visible-state evidence, not a diagnosis or a complete record of every event.
- Self-contained output does not automatically embed externally linked images; lifecycle and delivery checks remain necessary.
HOOK
Recorder, photo, envelope.
TELL A FRIEND
Recorder and a dashboard photo.
OFTEN MIXED UP WITH Selenium from zero: install, driver set-up and a first script that opens a page. That topic installs Selenium and runs a . This one makes the results readable for the team.
Sources & standards — 2 sources
- Implementation-specific
pytest-html user guide ↗ — pytest-dev contributors · Creating a self-contained report; extra content APIs; preserving extras and report phases (selected actual primary passages read 7 November 2026; live publisher documentation; no fixed edition claimed).
Selected actual primary passages read on the access date, not every linked guide. Live documentation, tagged package metadata and W3C2018 have distinct scopes. Daily List rules, people, identifiers and observations are synthetic. Educational sequences do not claim installation, vendor-package or live-app execution.
- Implementation-specific
pytest fixture guide ↗ — pytest-dev contributors · Fixture scopes and teardown; yield-fixture lifecycle and teardown limitations (selected actual primary passages read 7 November 2026; live publisher documentation; no fixed edition claimed).
Selected actual primary passages read, including the specific fixture/marker/collection boundaries described. Daily List rules, people and paths are synthetic; no pytest/xdist execution or complete production fixture design is claimed. Live documentation has no fixed edition claimed.
PRACTISE AND KEEP
Sources for this topic — 2 sources
- Implementation-specific
pytest-html user guide ↗ — pytest-dev contributors · Creating a self-contained report; extra content APIs; preserving extras and report phases (selected actual primary passages read 7 November 2026; live publisher documentation; no fixed edition claimed).
Selected actual primary passages read on the access date, not every linked guide. Live documentation, tagged package metadata and W3C2018 have distinct scopes. Daily List rules, people, identifiers and observations are synthetic. Educational sequences do not claim installation, vendor-package or live-app execution.
- Implementation-specific
pytest fixture guide ↗ — pytest-dev contributors · Fixture scopes and teardown; yield-fixture lifecycle and teardown limitations (selected actual primary passages read 7 November 2026; live publisher documentation; no fixed edition claimed).
Selected actual primary passages read, including the specific fixture/marker/collection boundaries described. Daily List rules, people and paths are synthetic; no pytest/xdist execution or complete production fixture design is claimed. Live documentation has no fixed edition claimed.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.