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 “http://www.microsoft.com/en-in/download/confirmation.aspx?id=27870”
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.
5. Create object of ScreenCaptureJob in your test.
6. Sample code for screen capturing
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
For screen capturing Microsoft provide” Microsoft Expression Encoder 4” which can be download and install from link “http://www.microsoft.com/en-in/download/confirmation.aspx?id=27870”
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;
ScreenCaptureJob scj = new
ScreenCaptureJob();
using NUnit.Framework;
using OpenQA.Selenium;
using Microsoft.Expression.Encoder.ScreenCapture;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;
namespace ScreenRecording.TestScript
{
[TestFixture]
public class ScreenRecording
{
IWebDriver driver;
ScreenCaptureJob scj;
[SetUp]
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
scj.Start();
driver = new FirefoxDriver();
}
[TestCase]
public void TestGoogleSearch()
{
driver.Navigate().GoToUrl("http://www.google.com/");
IWebElement query =
driver.FindElement(By.Name("q"));
query.SendKeys("testing");
Assert.AreEqual("testing -
Google Search", driver.Title);
}
[TearDown]
public void TestCleanUp()
{
//Close the Browser
driver.Close();
//Stop the Screen Captureing
scj.Stop();
}
}
}
8. Build and run above code using Nunit , after execution a video file will generate at mentioned location and file
similar post in webdriver java for screen recording
ReplyDeletehttp://roadtoautomation.blogspot.in/2013/03/screen-recording-video-of-java-webdiver.html
Thanks for this blog
ReplyDeleteThank you. It is helpfull..
ReplyDeleteGreat 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:
ReplyDeleteNo such interface supported [0x80004002]
[FileInfo]
FileExtension=.wmv
FileSize=581128
FourCC=MTS2
AudioTag=0000
[FilterRenderError]
CLSID="{187463A0-5BB7-11D3-ACBE-0080C75E246E}"
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?
@Mat z: try to save as a *.xesc file instead, that did the trick for me.
ReplyDelete@Mat z
ReplyDeleteUse *.xesc extension instead: this did the trick for me.
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?
ReplyDeleteThanks for the post, how do you make it record the focused screen when you have multiple monitors?
ReplyDeleteHi
ReplyDeleteI want to record video in selenium grid,How to do that since code is in grid and it will be executed in node.