Search code examples
javaseleniumselenium-webdriverwebpage-screenshot

Selenium screenshot in IE


For screenshot we are using below code

File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);                         
FileUtils.copyFile(scrFile, new File("C:\\Screenshot\\Test_Screenshot.png")); 

It takes the screenshot without any issues in IE but i want to capture the complete screen including taskbar and URL.

Could someone please help or share if it is posible in IE.

Thanks, Awaiting Reply


Solution

  • Use screenshot capabilities of Robot instead of selenium: http://download.oracle.com/javase/6/docs/api/java/awt/Robot.html#createScreenCapture%28java.awt.Rectangle%29

    BufferedImage image = new Robot().createScreenCapture(new    Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
    ImageIO.write(image, "png", new File("/screenshot.png"));
    

    Refer: How to take a screenshot in Java?