Skip to content
Merged
Changes from 3 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
18 changes: 13 additions & 5 deletions java/src/org/openqa/selenium/OutputType.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,23 @@ public File convertFromPngBytes(byte[] data) {
}

private File save(byte[] data) {
Path tmpFilePath = null;
try {
Path tmpFilePath = Files.createTempFile("screenshot", ".png");
File tmpFile = tmpFilePath.toFile();
tmpFile.deleteOnExit();
tmpFilePath = Files.createTempFile("screenshot", ".png");
Files.write(tmpFilePath, data);
return tmpFile;
} catch (IOException e) {
throw new WebDriverException(e);
String pathInfo =
(tmpFilePath != null)
? tmpFilePath.toAbsolutePath().toString()
: "temporary file could not be created";

throw new WebDriverException(
"Failed to create or write screenshot to temporary file: " + pathInfo, e);
}

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

public String toString() {
Expand Down
Loading