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?