Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recording Selenium test execution with Expression Encoder 4 SDK fails on build server

We run Selenium tests nightly on our TeamCity build server.

We have some tests that fail intermittenly during our nightly run.

Screenshots of failed tests haven't really provided an answer, so I want to record the execution of failed tests.

I have implemented the following to record test execution of tests I want to investigate.

        ScreenCaptureJob = new ScreenCaptureJob
        {
            CaptureRectangle = Screen.PrimaryScreen.Bounds,
            ShowFlashingBoundary = true,
            OutputPath = outputPath
        };

        ScreenCaptureJob.Start();

        Debug.WriteLine($"Status: {ScreenCaptureJob.Status}");

        Test code...

        ScreenCaptureJob.Stop();

If the test fails I encode the captured video and save it. This works fine when I run the test locally.

But, when I run this on the build server the ScreenCaptureJob has a status of NotStarted.

No temp file is written to disc, so there is nothing to encode when the test fails.

        MediaItem mediaItem = new MediaItem(fileName);
        Job job = new Job();
        job.MediaItems.Add(mediaItem);
        job.ApplyPreset(Presets.VC1HD720pVBR);
        job.OutputDirectory = outputPath;
        job.Encode();

Exception occurs when I try to create a new MediaItem from the temp file.

TestCleanup method UITests.FailingTest.TestCleanup threw exception. Microsoft.Expression.Encoder.InvalidMediaFileException: Microsoft.Expression.Encoder.InvalidMediaFileException: File not found.

EE4 is installed on the build server, and I have tested capturing with the EE4 program itself.

Does anyone have an idea of why the ScreenCaptureJob fails to start on the server?

like image 607
jandig Avatar asked Mar 31 '16 13:03

jandig


1 Answers

Running tests on Windows Server require you to add the feature

User Interfaces

and

Infrastructure > Desktop Experience

to install missing dependencies required by Microsoft Expression Encoder.

If you already did this and it doesn't work read this article, it is very helpful and there is a link to GitHub profile with the code used for the video recording. The author uses ScreenCaptureJob thru interface which sounds great.

like image 86
TheCodeLord Avatar answered Oct 01 '22 21:10

TheCodeLord