Road to screen recording in webdriver with C#

Last couple of days, I am searching screen recording by using webdriver with C# similar to “Monte Media Library” in java and finally I got the solution. Here, I am posting my finding so that it can help others.
For screen capturing Microsoft provide” Microsoft Expression Encoder 4” which can be download and install from link “

Default installation directory is “C:\Program Files\Microsoft Expression”.

Steps to create and run webdriver test.

1. You need to make sure that you have setup all required dll for of webdriver and Nunit.
2. Download and install”Microsoft Expression Encoder 4” from above mentioned url.
3. Add “Microsoft.Expression.Encoder.dll” from “C:\Program Files\Microsoft Expression\Encoder 4\SDK” folder to your webdriver project.
4. You need to add import below class in your test.
using Microsoft.Expression.Encoder.ScreenCapture;
5. Create object of ScreenCaptureJob in your test.
ScreenCaptureJob scj = new ScreenCaptureJob();
6. Sample code for screen capturing
using NUnit.Framework;
using OpenQA.Selenium;
using Microsoft.Expression.Encoder.ScreenCapture;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;

namespace ScreenRecording.TestScript
   public class ScreenRecording
       IWebDriver driver;
       ScreenCaptureJob scj;

       public void TestSetup()
           // Create a instance of ScreenCaptureJob
           scj = new ScreenCaptureJob();

           // Specify the path & file name in which you want to save         
           scj.OutputScreenCaptureFileName = @"C:\ScreenRecording.wmv";

           // Start the Screen Capture Job
           driver = new FirefoxDriver();

       public void TestGoogleSearch()
           IWebElement query = driver.FindElement(By.Name("q"));
           Assert.AreEqual("testing - Google Search", driver.Title);

       public void TestCleanUp()
           //Close the Browser
           //Stop the Screen Captureing

7. Set file name and path in “scj.OutputScreenCaptureFileName = @"C:\ScreenRecording.wmv"; “
8. Build and run above code using Nunit , after execution a video file will generate at mentioned location and file


  1. similar post in webdriver java for screen recording

  2. Great post. I have a question about the format in which the movie is saved. It is said that it is .wmv. but Windows Media Player can't open the movie as the codec missing message is appearing. The other player is throwing the following error:
    No such interface supported [0x80004002]


    Filter="C:\Users\xxxxxxxxx\Desktop\Recording - 27-01-2016-11-53-46.wmv"
    Pin="Raw Video 0"
    Major Type: Video - Sub Type: Unknown Format: VideoInfo MTS2 1920X1080, 24

    Could you please help with this?

  3. @Mat z: try to save as a *.xesc file instead, that did the trick for me.

  4. @Mat z

    Use *.xesc extension instead: this did the trick for me.

  5. GUys , I set everything , and I am not getting any error , or anything else. everything is working smoothly but there is no Recorded file in path , or anywhere else. Does anyone has any idea about my problem?

  6. Thanks for the post, how do you make it record the focused screen when you have multiple monitors?


Leave your comments, queries, suggestion I will try to provide solution