Playwright + Java · Lesson 38 of 38

0/38 done

Module 38: Reporting

38. Test Reporting, Video Recording & CI Artifact Management

16 minlesson

Your task

Implement calculatePassRate:

  1. Accept int passed and int total.
  2. If total == 0, return 0.0.
  3. Otherwise return ((double) passed / total) * 100.0.

Write it in the editor, then press Check answer (Ctrl + Enter).

Enabling Video Recording & Artifacts

java
// Record videos for failed tests:
BrowserContext context = browser.newContext(new Browser.NewContextOptions()
    .setRecordVideoDir(Paths.get("videos/"))
    .setRecordVideoSize(1280, 720));

Page page = context.newPage();
// Run test...

// Save video path on test failure:
context.close();
System.out.println("Video saved to: " + page.video().path());

Clean Test Execution Summary

java
public class TestResultSummary {
    private final int total;
    private final int passed;
    private final int failed;

    public TestResultSummary(int total, int passed, int failed) {
        this.total = total;
        this.passed = passed;
        this.failed = failed;
    }

    public double getPassRate() {
        return total == 0 ? 0 : ((double) passed / total) * 100.0;
    }
}

Key Takeaways & Walkthrough Summary

In our final module of Playwright with Java, we configure comprehensive test reporting. You will learn to record execution videos, generate clean HTML test summaries, attach screenshots on failure, and analyze test results. Congratulations on reaching the capstone module!

Part of the Playwright + Java course (Playwright with Java). Practice this concept live in the Playwright Online Compiler or explore our free automation practice form.

Common Doubts & Lesson Q&A

When does Playwright write the video file to disk?

Playwright flushes and finalizes the video file when the BrowserContext is closed. Always close the context before reading page.video().path().

Ready? Solve the task in the editor

Use Check answer to mark it complete. Hints are there if you need them.

Java
Finish course