Capture screenshots on failure
Hard120 pts~45 min
- Screenshots
- Test hooks
- Debugging
Practice app · Acme Ops
A sign-in page with field validation and an authenticated dashboard.
Your starter code already declares TEST_URL — never hardcode a host.
Objective
Capture a screenshot automatically whenever a test fails, before the driver quits.
Your task
- 1Add a failure hook: JUnit 5 TestWatcher/AfterTestExecutionCallback, pytest_runtest_makereport, NUnit TearDown checking TestContext.CurrentContext.Result, or Mocha afterEach checking this.currentTest.state.
- 2In the hook save a screenshot (TakesScreenshot / save_screenshot) as screenshots/<test-name>-<timestamp>.png.
- 3Make sure the hook runs before driver.quit().
- 4Sign in with qa@target.dev / Test@123 (#username, #password, #login-button). Assert the dashboard — the passing run produces no screenshot.
Acceptance criteria
- A screenshot is captured from a failure hook
- The dashboard is shown
- At least 1 assertion passes
Fixtures
- username
- qa@target.dev
- password
- Test@123
Selenium WebDriver 4 · SDET · Grid, parallel & CI