Skip to main content

Posts

Showing posts from August, 2018

Screenshot in Selenium Webdriver (C#)

Selenium WebDriver provides the option to capture screenshots during a test execution. This is very important when we need to investigate different failures in test cases or unexpected window popup during test execution or in some cases to track the different stages of the run. Sometimes we need the screenshots to understand at the end of long running test execution on why the test case got failed.We can save the screenshots in a local folder of our computer. In Selenium Webdriver the screen shots are taken using Screenshot class. The ITakesScreenshot interface has method called GetScreenshot() which takes screenshot of the page on the screen. Here is the Code to take screenshot of a page.          #region screenshots public class ScreenShotClass { public static string Save (IWebDriver driver, string ScreenShotFileName) { var folderLocation = ( @"" );//Path of the folder to save the file