MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / OutputType

Interface OutputType

java/src/org/openqa/selenium/OutputType.java:32–132  ·  view source on GitHub ↗

Defines the output type for a screenshot. @see TakesScreenshot @param Type for the screenshot output.

Source from the content-addressed store, hash-verified

30 * @param <T> Type for the screenshot output.
31 */
32public interface OutputType<T> {
33 /** Obtain the screenshot as base64 data. */
34 OutputType<String> BASE64 =
35 new OutputType<String>() {
36 @Override
37 public String convertFromBase64Png(String base64Png) {
38 return base64Png;
39 }
40
41 @Override
42 public String convertFromPngBytes(byte[] png) {
43 return Base64.getEncoder().encodeToString(png);
44 }
45
46 public String toString() {
47 return "OutputType.BASE64";
48 }
49 };
50
51 /** Obtain the screenshot as raw bytes. */
52 OutputType<byte[]> BYTES =
53 new OutputType<byte[]>() {
54 @Override
55 public byte[] convertFromBase64Png(String base64Png) {
56 return Base64.getDecoder().decode(base64Png);
57 }
58
59 @Override
60 public byte[] convertFromPngBytes(byte[] png) {
61 return png;
62 }
63
64 public String toString() {
65 return "OutputType.BYTES";
66 }
67 };
68
69 /**
70 * Obtain the screenshot into a temporary file that will be deleted once the JVM exits. It is up
71 * to users to make a copy of this file.
72 */
73 OutputType<File> FILE =
74 new OutputType<File>() {
75 @Override
76 public File convertFromBase64Png(String base64Png) {
77 return save(BYTES.convertFromBase64Png(base64Png));
78 }
79
80 @Override
81 public File convertFromPngBytes(byte[] data) {
82 return save(data);
83 }
84
85 private File save(byte[] data) {
86 Path tmpFilePath = createScreenshotFile();
87 try {
88 Files.write(tmpFilePath, data);
89 } catch (IOException e) {

Callers 19

testBase64Method · 0.80
testBytesMethod · 0.80
testFilesMethod · 0.80
getScreenshotAsMethod · 0.80
getScreenshotAsMethod · 0.80
getScreenshotAsMethod · 0.80
getScreenshotAsMethod · 0.80
_wrapFunction · 0.65
domcore.jsFile · 0.65
observeMutationsFunction · 0.65

Calls

no outgoing calls

Tested by

no test coverage detected