Wednesday 16 January 2013

How to take screenshot using selenium Webdriver?

How to take screenshot using selenium Webdriver?


By Using  below code you can take screenshot of current webpage:

driver.get("http://google.com");            
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("E://google.png"));



2 comments:

  1. Obtained screenshot is of size 999x16476 and is too small,how to obtain screenshot of other sizes

    ReplyDelete
    Replies
    1. Hi,

      Try the below code.
      driver.manage().window().setSize(new Dimension(1024, 768));

      Delete