Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to video-record selenium tests running headless inside a docker?

Tags:

I am running python-selenium tests inside a docker using a headless firefox.

During these tests I am able to make screenshots with the selenium method for screenshots - but can I use something to 'video' record the virtual display during the whole test (several test scripts with several test methods, with many webdrivers started and stopped).

So how can I video-record a complete test session?

Addendum: I have found a webpage that describes exactly what I need: here. Unfortunately I get an error when I try to do the recording. Here are the commands I am doing:

xvfb-run --listen-tcp --server-num 44 --auth-file /tmp/xvfb.auth -s "-ac -screen 0 1920x1080x24" python seltest.py &
ffmpeg -f x11grab -video_size 1920x1080 -i 127.0.0.1:44 -codec:v libx264 -r 12 /tmp/behat_1.mp4

and the error is (for the second command):

[x11grab @ 0x1d289c0] Cannot open display 127.0.0.1:44, error 1.
127.0.0.1:44: Input/output error
like image 255
Alex Avatar asked Jul 05 '18 13:07

Alex


People also ask

Can you run Selenium headless?

Yes, Selenium supports headless testing. In older versions of Selenium, we used the HTMLUnitDriver mainly, a headless driver providing a Non-GUI implementation of Selenium WebDriver.

What would you use to run your tests in a headless mode?

Headless Testing With Selenium Selenium is a free, open-source testing tool. It is a quite well-known and efficient automation tool for performing automation tests. Selenium allows us to write test scripts in various languages like Java, Python, C#, Ruby, Perl, Scala, etc.


1 Answers

The correct steps to record the virtual display with ffmpeg are:

xvfb-run --listen-tcp --server-num 44 --auth-file /tmp/xvfb.auth -s "-ac -screen 0 1920x1080x24" python seltest.py &
export DISPLAY=:44
ffmpeg -f x11grab -video_size 1920x1080 -i :44 -codec:v libx264 -r 12 video.mp4
like image 75
Alex Avatar answered Sep 20 '22 01:09

Alex