I have created screenShot()
method to take the screenshot of the web page. When I used this method in my code first time it will capture the screen and it will save the image with image1
name. When I used the same method screenShot()
to capture screens for other pages with the use of this.screenShot();
this will again capture the current web page screen but it stores With the same name image1
in the same folder (which overrides to previously captured screen image1).
Now, I have to take screenshots for the number of web pages & want to store it into the same folder with different names like image1, image2, image3...etc. by using the same method screenShot()
.
public void screenShot() throws IOException, InterruptedException
{
File scr = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
File dest = new File("filPath/image1.png");
FileUtils.copyFile(scr, dest);
}
Any workaround to achieve this scenario?