Playwright + Python · Lesson 37 of 37
Module 37: Reporting
Your task
Implement calculate_pass_percentage(passed, total):
Write it in the editor, then press Check answer (Ctrl + Enter).
# Generate clean HTML report:
pytest --html=reports/test_report.html --self-contained-htmlcontext = 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())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.
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.
___