Playwright + Python · Lesson 37 of 37

0/37 done

Module 37: Reporting

37. Comprehensive Test Reporting & CI Execution Summaries

16 minlesson

Your task

Implement calculate_pass_percentage(passed, total):

  1. If total <= 0, return 0.0.
  2. Return (passed / total) * 100.0.

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

Generating Rich HTML Reports

bash
# Generate clean HTML report:
pytest --html=reports/test_report.html --self-contained-html

Recording Videos on Failure

python
context = browser.new_context(record_video_dir="videos/")
page = context.new_page()
# Run test...
context.close() # Video is flushed and finalized on context close
print("Video saved:", page.video.path())

Key Takeaways & Walkthrough Summary

In our final module of Playwright with Python, we configure comprehensive test reports. You will learn to generate rich HTML reports with pytest-html, attach failure screenshots, and inspect test videos. Congratulations on completing the course!

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

Common Doubts & Lesson Q&A

When does Playwright save the video file to disk?

Playwright finalizes and saves the video file when context.close() is called. 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.

Python
Finish course