Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Avoid using a temporary file to store screenshot after a test failure #1855

Merged
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
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package org.jenkinsci.test.acceptance.junit;

import jakarta.inject.Inject;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.logging.Logger;
import org.apache.commons.io.FileUtils;
import org.jenkinsci.test.acceptance.controller.JenkinsController;
import org.jenkinsci.test.acceptance.po.CapybaraPortingLayerImpl;
import org.junit.rules.TestWatcher;
Expand Down Expand Up @@ -44,10 +43,9 @@ protected void failed(Throwable t, Description description) {

private void takeScreenshot() {
try {
File file = diagnostics.touch("screenshot.png");
File screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshot, file);

Files.write(
diagnostics.touch("screenshot.png").toPath(),
((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES));
} catch (IOException e) {
logger.warning("An error occurred when taking screenshot");
throw new Error(e);
Expand Down
Loading