Playwright + Python · Lesson 32 of 37
Module 32: Screenshots, Video & Trace
Your task
Implement start_tracing_session(context):
Write it in the editor, then press Check answer (Ctrl + Enter).
# Start tracing before actions:
context.tracing.start(screenshots=True, snapshots=True, sources=True)
# Run test actions...
# Stop and save trace archive:
context.tracing.stop(path="traces/failure_trace.zip")
# View trace with CLI:
# playwright show-trace traces/failure_trace.zipWhen tests fail on remote CI runners, Playwright's Trace Viewer provides an interactive time-travel debugging experience. In this lesson, you will master configuring traces, screencasts, and viewing failure traces. Let's master the Trace Viewer!
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.
Run pytest with 'pytest --tracing=retain-on-failure' to automatically save traces only when tests fail.
Ready? Solve the task in the editor
Use Check answer to mark it complete. Hints are there if you need them.
___