Frames and Files
Videos in Playwright
Videos in Playwright: definition, recording setup, CI debugging usage, mistakes, interview notes, and practice.
Definition and Brief Explanation
Definition: Videos in Playwright record browser execution for a test when video capture is enabled in configuration or context options.
Explanation: Videos help explain how a failed test reached its final state. They are especially useful for CI failures where you cannot watch the browser live.
Why It Matters
- It shows the full sequence that led to a failure.
- It helps debug CI failures that cannot be watched live.
- It is useful for timing, animation, navigation, and unexpected overlay issues.
- It provides evidence that screenshots alone may miss.
How It Works
- Enable video in Playwright config or browser context options.
- Run the test normally.
- Review the video from test artifacts after failure or completion.
- Use the video with trace and report details to identify the root cause.
Syntax and Examples
Example 1: Video on failure
use: { video: 'retain-on-failure' }
Explanation: Keeps video only for failed tests to reduce storage size.
Common Mistakes
- Recording every test forever and creating huge artifacts.
- Using video instead of reading the error and trace.
- Forgetting to upload videos in CI.
- Assuming video alone explains network or console failures.
Interview Notes
- How do you enable video recording?
- When is video more useful than a screenshot?
- Why can video artifacts become expensive?
- How do you use video with trace viewer?
Practice Task
Enable video for a small failing test, run it, and explain what the video shows that the final screenshot does not.