7

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?

jandig
  • 91
  • 1
  • 6

1 Answers1

1

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.

TheCodeLord
  • 417
  • 6
  • 12
  • Thank you for your reply. Both features are enabled on the server. As I said initially, tests are running on the build server. And recording with ScreenCaptureJob works fine when running the tests locally. It just doesn't work on the server. – jandig Apr 19 '16 at 10:47