Saturday, July 2, 2016

Selenium Grid with Windows video recording support

In a previous article I've shown you how to add video recording support into Selenium Grid to be able to run it in Docker containers on Linux. We'll extend Grid to record tests both on Linux and Windows this time.

To make a single cross-platform solution, we'll replace avconv with ffmpeg. As these tools are almost similar, there's no need in updating key recording commands.

Main updates will affect OS-specific recorder and display options. Fortunately, ffmpeg supports GDI-based screen capture device called gdigrab, which is an out of the box Windows device. In case of using this recorder, we should specify desktop input.
Next thing we need to care of is related to graceful process stopping operation. INT signal is supported on Linux out of the box, but there's no easy way to do the same on Windows. So we'll use a special tool written in C to achieve this goal. It will be included into Grid resources. We just need to to take care of its extraction into OS-specific temporary folder on jar's startup. This could be done via custom launcher implementation.
Let's modify stopVideoRecording API to support graceful ffmpeg process stopping.
That's it. There's one more point I'd like to cover. As we replaced avconv with ffmpegdocker-selenium project should be updated as well.
ffmpeg is missing from official Ubuntu repository. So first we need to add a custom one, and then install appropriate tool.

You can find sources on GitHub as usual. Don't forget to install ffmpeg and put it into system path. Happy coding. :)