Record video of your Selenium Tests

We have just finished optimizing the video recording in our Selenium grid.
Implementing this was harder than we thought, so here are some tips on how we implemented this.

To create a video, we used AForge’s AviWriter, which makes creating avi videos very easy in C#.
We first started off with using C# and Windows’ PrintWindow function. This worked in some cases but would sometimes show a dark square in the content area.
PrintWindow was also very slow when appending it to a video.

Next, we tried to use Bitblt and GDI with C#, together with AviWriter. This was still too slow for us as it caused tests to run twice as long. We want your tests to run as fast as possible and did not want to hog the CPU because of video recording.

After searching on Google, we found several costly screen capture SDKs which promised fast video recording by using special drivers. This turned out to be working in some cases, but was still too slow.

Finally, we investigated Microsoft Expression Encoder which offers a screen-capture SDK. This turned out to be a winner since it recorded video without hogging the CPU.
The only pitfall is that the video encoding used by this SDK is a proprietary encoding by Windows. To convert the video to FLV, we needed to encode it after recording, something that requires quite a lot of CPU.

We choose to do the video recording on a different high CPU server, so that your tests will run as fast as possible without a screen recording slowing down the CPU.

The program we’re using to take screenshots is MiniCap, which is a lightweight command line program to easily take screenshots. Highly recommended.

It was quite a journey, but we think we now have a good system to record tests without slowing down your tests.

No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *