Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions java/src/org/openqa/selenium/OutputType.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,29 @@ public File convertFromPngBytes(byte[] data) {
}

private File save(byte[] data) {
Path tmpFilePath = createScreenshotFile();
try {
Path tmpFilePath = Files.createTempFile("screenshot", ".png");
File tmpFile = tmpFilePath.toFile();
tmpFile.deleteOnExit();
Files.write(tmpFilePath, data);
return tmpFile;
} catch (IOException e) {
throw new WebDriverException(e);
throw new WebDriverException(
"Failed to create or write screenshot to temporary file: "
+ tmpFilePath.toAbsolutePath().toString(),
e);
}

File tmpFile = tmpFilePath.toFile();
tmpFile.deleteOnExit();
return tmpFile;
}

private Path createScreenshotFile() {
try {
return Files.createTempFile("screenshot", ".png");
} catch (IOException e) {
throw new WebDriverException(
"Failed to create or write screenshot to temporary file: "
+ "temporary file could not be created",
e);
}
}

Expand Down