DEV Community

Cesar Augusto Rayo Zapata
Cesar Augusto Rayo Zapata

Posted on • Updated on

Docker-Selenium Video Recorder

This post is intended for all those who use docker-selenium.

Since I started using "dockerized" Selenium grid, I was always curious about the possibility of recording the actions we perform within a browser container (chrome, edge, firefox) and when I saw there was a solution in place for it, I just jumped into it, it was basically by using selenium/video:ffmpeg-XXXX Docker image; starting and stoping containers manually, but it was quite too raw, mainly because of the fact we need to kill the container in order to get the video file.

So I tried to create a logic layer whose main task was going to be handle this situation; avoid start/stop containers every time. As the thing got more complex and wanted to get more control, I ended up creating a service that can be deployed either using docker-compose or Helm Chart.

The service is intended to be exposed in the port 5001 of the machine where Selenium Grid is running, and it will look something similar to this:

Start recording the screen of a given node:

$ curl -X POST http://localhost:5001/start -H "Content-Type: application/json" -d '{"videoName":"my_video","targetDisplay":"chrome-display"}'
{"file": "my_video.mp4", "status": "recording"}
Enter fullscreen mode Exit fullscreen mode

Stop recoding

$ curl -v -X POST http://localhost:5001/stop
{"file": "my_video.mp4", "status": "stopped"}
Enter fullscreen mode Exit fullscreen mode

The file will be saved on the path you have specified in the deployment (keep reading for more details)

It's obviously the first steps for having a robust service that can take advantage of the replicas we might have in the Helm Chart or the Compose deployment, but this is a solution that worked for me and hope it does for you!

All that intro just for sharing this with you Selenium Grid + Video Recorder, Happy testing!!

Top comments (0)