23

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
mmoya
  • 1,901
  • 1
  • 21
  • 30
Alex
  • 41,580
  • 88
  • 260
  • 469

2 Answers2

15

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
Alex
  • 41,580
  • 88
  • 260
  • 469
0

As the article provides, there are couple things to try:

You can fix the “cannot open display” error by following the xhost procedure:

  1. Allow clients to connect from any host using xhost+ Execute the following command to disable the access control, by which you can allow clients to connect from any host.

    $ xhost + 
    access control disabled, clients can connect from any host
    
  2. Enable X11 forwarding While doing ssh use the option -X to enable X11 forwarding.

    $ ssh username@hostname -X 
    

    Enable trusted X11 forwarding, by using the -Y option,

    $ ssh username@hostname -Y
    
  3. Open GUI applications in that host After opening ssh connection to the remote host as explained above, you can open any GUI application which will open it without any issue.

    If you still get the “cannot open display” error, set the DISPLAY variable as shown below.

    $ export DISPLAY='IP:0.0' 
    

    Note: IP is the local workstation’s IP where you want the GUI application to be displayed.

EDIT:

hostname:n.m

Where hostname is the network hostname, qualified with domain name as needed (or use the IP address directly); n is the display number on that host (usually 0); and m is the screen number on that host (usually 0).

So try to replace 127.0.0.1:44 with 127.0.0.1:n.m. If you have multiple displays try to find out which one will work by passing 127.0.0.1:0.0, 127.0.0.1:0.1, 127.0.0.1:1.0 ...

Also check if display dimensions is really 1920x1080.

Andrei Suvorkov
  • 5,559
  • 5
  • 22
  • 48
  • These suggestions still do not work. Also I cannot try suggestion 2, as I am trying the example on the same local machine. I do not use ssh at all! For suggestion 3 I used `export DISPLAY='localhost:0.0'`... – Alex Jul 09 '18 at 14:54
  • I am not able to try all possible combinations. I tried some, but I have no success. The error message is still `Cannot open display 127.0.0.1:44, error 1. 127.0.0.1:44: Input/output error` – Alex Jul 10 '18 at 05:26
  • Please try `127.0.0.1:10.0` I have read, that it often helps – Andrei Suvorkov Jul 10 '18 at 07:13