How to Capture multiple screenshots (not overriding the previous one)through selenium webdriver using aShot class. I am able to run 2 test cases and can see screenshot is being captured for both of the test cases however screenshot only got copied in the folder for the current case.Below code i am using to take full screenshot using aShot class.
public static void captureFullPage() throws IOException
{
screenshotName = d.toString().replace(":", "_").replace(" ", "_")+ "PNG";
Screenshot screenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(1000)).takeScreenshot(driver);
String dest = System.getProperty("user.dir") + "\\TestOutput\\" + screenshotName;
ImageIO.write(screenshot.getImage(), "PNG", new File(dest));
//return dest;
}
Write code as
This code will help you take screenshot with different names each time as it includes timestamp in its name so that overriding of previous screenshots will not happen and you will get all of your screenshots. make changes in this code as per your taste.