I understand that videos play an important role in Test Automation. Some people think that videos
are not so much important in test automation, but my experience taught me that even videos give you lot of information that lets every one knows what happens during test execution, and other information that happens during test execution.
Here, I would like to explain a very simple mechanism to have your scripts generate videos of your test scripts. We know that capturing videos are little tricky and need to depend on some third party tools. Here is a third party freeware/open source using which we can have the videos generated for our scripts.
The example I describe would be in php as some people do not get an idea how to capture videos using php, as php is not flexible to use like other high level languages such as C#, Java, etc.,
FFMpeg is an command line tool using which we can generate videos. And I do not want to describe a lot here, to let readers do their task immediately.
download the ffmepg from the link: http://ffmpeg.zeranoe.com/builds/
once you download the build extract the file and put ffmpeg.exe in your system path you define in Environment variable. example: C:\DriverCapture is my path i define in System environment varible "Path".
And then, write the command
command: ffmpeg -f dshow -i video=\"screen-capture-recorder\" -r 5 -threads 0 testMethod1.wmv
in your phpfunction. Now use shell_exec(command) to launch the video.
example:
public function StartVideoThreadForTest($testMethodName)
{
//Run the Command to Start running the video without CaptureVideo.exe
$cmd="ffmpeg -f dshow -i video=\"screen-capture-recorder\" -r 5 -threads 0 ".$testMethodName.".wmv";
shell_exec($cmd);
}
Now call this method before your test runs. To stop the video capture use the following command to stop:
shell_exec('taskkill /F /IM ffmpeg.exe');
But, When you run your script you observe that your execution does not move from video launch command, to make it work.
Create a .NET console project and put the following code in the Main method.
namespace CaptureVideo
{
class Program
{
static void Main(string[] args)
{
Process ffmpeg = new Process();
ffmpeg.StartInfo.FileName = "c:\\seleniumDrivers\\ffmpeg";
ffmpeg.StartInfo.Arguments = " -f dshow -i video=\"screen-capture-recorder\" -r 5 -threads 0 -y "+args[0]+".wmv";
ffmpeg.Start();
}
}
}
In the above program I put the ffmpeg in the c:\seleniumDrivers\ folder.
Compile the above program, you will see an exe (CompiledVideo.exe - project name) generated inthe debug folder. Noe put the compiled exe in the system path you used to place ffmpeg directory.
And now use the following php function to run the video recorder on background:
public function StartVideoThreadForTest($testMethodName)
{
//Run the Command to Start running the video without CaptureVideo.exe
//$cmd="ffmpeg -f dshow -i video=\"screen-capture-recorder\" -r 5 -threads 0 ".$testMethodName.".wmv";
$path=__DIR__.'/../../../Output/';
$cmd="CaptureVideo ".$path.$testMethodName."-".time();
shell_exec($cmd);
}
No comments:
Post a Comment