-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScreenshotHelper.java
43 lines (35 loc) · 1.16 KB
/
ScreenshotHelper.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
package com.fs.app.automation.ScreenshotUtils;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
class ScreenshotHelper {
private static final ThreadLocal<Map<String, Object>> SCREEN_SHOTS = new ThreadLocal<Map<String, Object>>() {
@Override
protected Map<String, Object> initialValue() {
return new HashMap<>();
}
};
public static void add(String name, byte[] image) {
SCREEN_SHOTS.get().put(name, image.clone());
}
public static Map<String, Object> getScreenShotsForCurrentTest() {
return SCREEN_SHOTS.get();
}
public static void tidyUpAfterTestRun() {
SCREEN_SHOTS.remove();
}
public static byte[] imageToByteArray(BufferedImage image) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
try {
ImageIO.write(image, "png", stream);
} catch(IOException e) {
throw new RuntimeException(e);
}
return stream.toByteArray();
}
}
*/