October 26, 2021

Enable video recording while executing test scripts using selenium .Net in Visual Studio

  October 26, 2021

 Logs are the perfect way to know what went wrong during the execution. What if we don't understand the error shown in the log?

A video recording of the execution will be the exact thing we may need in this scenario.

Visual Studio 2017 version 15.5 onwards supports this functionality inbuilt.

We just need to enter the configuration in the .runsettings file under DataCollectionRunSettings tag.

Enter the below code in your runsettings file and execute the test, this will add an attachment of video recording as part of the test output.

<DataCollectionRunSettings>
    <DataCollectors>

      <DataCollector uri="datacollector://microsoft/VideoRecorder/1.0" assemblyQualifiedName="Microsoft.VisualStudio.TestTools.DataCollection.VideoRecorder.VideoRecorderDataCollector, Microsoft.VisualStudio.TestTools.DataCollection.VideoRecorder, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" friendlyName="Screen and Voice Recorder">
        <Configuration>
          <!-- Set "sendRecordedMediaForPassedTestCase" to "false" to add video attachments to failed tests only -->
          <MediaRecorder sendRecordedMediaForPassedTestCase="true"  xmlns="">           
            <ScreenCaptureVideo bitRate="512" frameRate="2" quality="20" />
          </MediaRecorder>
        </Configuration>
      </DataCollector>

    </DataCollectors>
  </DataCollectionRunSettings>

We change the size of the file by changing parameters in the runsettings file.
logoblog

Thanks for reading Enable video recording while executing test scripts using selenium .Net in Visual Studio

Previous
« Prev Post

No comments:

Post a Comment

Fixing javascript error: Cannot read properties of null (reading 'querySelector') issue when using CSS identifier in selenium

 JavaScript is another way to interact with web elements when normal selenium methods fail to act. But one issue with javascript is, it does...