Selenium WebDriver : - How to capture screenshot

Selenium WebDriver : - How to capture screenshot

Java code to capture browser screen shot is as follows –

File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); //take picture of browser
                       
screenshotpath = "C:\\”+ "file1.png"; //path & file name of picture
                                               
try {
              
  FileUtils.copyFile(scrFile, new File(screenshotpath)); //.png file is copied from memory 
  to file system
           
} catch (IOException e) {
           
            e.printStackTrace();

}

Comments

Popular posts from this blog

Testing Webservice with SoapUI Having Windows Authentication

Data Driven Testing Using Selenium -WebDriver in Python

How to Re-run Failed Scenarios in Cucumber