Total Pageviews

Wednesday 10 September 2014

How to take a screenshot in selenium webdriver

Topic: How to take a screenshot in selenium web driver


Code: i have implemented in TestNG method

 @Test
  public void takeScreenShotTest() throws IOException
  {
 WebDriver driver=new FirefoxDriver();
driver.get("https://google.co.in");
File scrFile=((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("C:\\Users\\Dell\\Desktop\\GoogleScreenShot.jpg"));
  }


output:

No comments:

Post a Comment