Taking Screenshot using C# with Selenium

Taking screenshot  using C# with Selenium is very easy as it has a inbuilt function

//Taking Screenshot in C#

 Screenshot ss = ((ITakesScreenshot)Browser).GetScreenshot();
 string title = ScenarioContext.Current.ScenarioInfo.Title;
 string Runname = title + DateTime.Now.ToString("yyyy-MM-dd-HH_mm_ss");
 string screenshotfilename = "X:\\screenshots\\" + Runname + ".jpg";
 ss.SaveAsFile(screenshotfilename, System.Drawing.Imaging.ImageFormat.Jpeg);

And in the above code X is networked drive from any node so that it allows us to store the images when run from Jenkins

You may also like...