Workaround to record video in Selenium headless mode, including when using Selenium Gri #2897
Replies: 2 comments 9 replies
-
What is the point of running a headless browser inside a container? |
Beta Was this translation helpful? Give feedback.
-
When you're using Selenium in headless mode and try to record the screen, you’ll probably just get a big ol’ black screen. That’s because headless browsers don’t actually render the UI - they skip all the visual stuff to run faster. So yeah, there's nothing for your recording software to see. Chrome in headless mode is all about speed, not looks. It skips hardware acceleration and leaves out a bunch of graphical elements, which totally messes with screen recording. On the flip side, tools like Playwright and Cypress were built with this in mind - they’ve got video capture baked right in, even in headless mode. Selenium leans on external tools like FFmpeg to handle recording, which means setting it all up is a bit more work and can get pretty messy, especially in headless mode. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
How to Record Video in Selenium Headless Mode (Works with Selenium Grid)
By default, when using:
in Selenium—especially with Selenium Grid—you may get a completely black video. This happens because Chrome in headless mode doesn’t render a visible UI for the screen recorder to capture.
Workaround I Found (Tested)
Although it’s not the perfect solution, here’s a working approach:
Key Details
Example: If the test runs for 10 seconds → record ~10 seconds of screenshots
Demo Available
You can try a working example in this GitHub repository:
https://github.com/testervippro/selenium-headless-mode-demo
Other frameworks like Cypress and Playwright already make it much easier to record videos, even in headless mode. It would be great to see Selenium catch up in this area.
Beta Was this translation helpful? Give feedback.
All reactions