public static void takeScreenShot(){
// take screenshot
File srcFile = ((TakesScreenshot)dr).getScreenshotAs(OutputType.FILE);
try {
FileUtils.copyFile(srcFile, new File(System.getProperty("user.dir")+"//myScreenshot.jpg"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
The above code will save the screenshot in our current project.