How Can I take Screenshot using selenium Webdriver



  • Hello , please tell me how can i take the screenshot of webpage by using selenium Webdriver in java ??



  • Yes, it is possible. The following example is in Java:

    WebDriver driver = new FirefoxDriver();
    driver.get("http://www.google.com/");
    File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
    // Now you can do whatever you need to do with it, for example copy somewhere
    FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));
    

    This answer has been lifted from stackoverflow and written by Sergii Pozharov as the question could be useful to others within SQA.


Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2