Skip to content

Commit b906ac7

Browse files
authored
Fix multiple screenshots overwriting each other (#91)
Fixes #90 Signed-off-by: Zbynek Cervinka <[email protected]>
1 parent d45bf2e commit b906ac7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main/java/com/redhat/devtools/intellij/commonuitest/utils/screenshot/ScreenshotUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@
3131
*/
3232
public class ScreenshotUtils {
3333
static final String SCREENSHOT_LOCATION = "." + File.separator + "build" + File.separator + "screenshots" + File.separator;
34-
static final String SCREENSHOT_FILENAME = getTimeNow("yyyy_MM_dd_HH_mm_ss");
3534
static final String FILETYPE = "png";
36-
static final String SCREENSHOT_PATHNAME = SCREENSHOT_LOCATION + SCREENSHOT_FILENAME + "." + FILETYPE;
3735
private static final Logger LOGGER = Logger.getLogger(ScreenshotUtils.class.getName());
3836

3937
private ScreenshotUtils() {
@@ -53,7 +51,9 @@ public static File takeScreenshot(RemoteRobot remoteRobot) {
5351
if (!doesScreenshotDirExists) {
5452
Files.createDirectory(Paths.get(SCREENSHOT_LOCATION));
5553
}
56-
File screenshotFile = new File(SCREENSHOT_PATHNAME);
54+
String screenshotFilename = getTimeNow("yyyy_MM_dd_HH_mm_ss");
55+
String screenshotPathname = SCREENSHOT_LOCATION + screenshotFilename + "." + FILETYPE;
56+
File screenshotFile = new File(screenshotPathname);
5757
ImageIO.write(screenshotBufferedImage, FILETYPE, screenshotFile);
5858
return screenshotFile;
5959
} catch (IOException e) {

0 commit comments

Comments
 (0)