66import java .io .InputStream ;
77import java .nio .file .Files ;
88import java .nio .file .Path ;
9+ import java .nio .file .StandardCopyOption ;
910import java .util .UUID ;
1011import java .util .logging .Level ;
1112import java .util .logging .Logger ;
@@ -52,7 +53,7 @@ public void handleTestExecutionException(ExtensionContext context, Throwable cau
5253 private void captureScreenshots (ExtensionContext context ) {
5354 final TestEnvironment environment ;
5455 if (context .getRequiredTestInstance () instanceof AbstractSeleniumTest ) {
55- AbstractSeleniumTest testInstance = (AbstractSeleniumTest ) context .getRequiredTestInstance ();
56+ final AbstractSeleniumTest testInstance = (AbstractSeleniumTest ) context .getRequiredTestInstance ();
5657 environment = testInstance .getEnvironment ();
5758 } else {
5859 throw new IllegalStateException ("The test instance must be of type AbstractSeleniumTest to use the ScreenShotRule." );
@@ -74,6 +75,7 @@ private void captureScreenshots(ExtensionContext context) {
7475 final File destinationDir = new File (screenshotFolder , context .getRequiredTestClass ().getName ());
7576 destinationDir .mkdirs ();
7677 final File destination = new File (destinationDir , filename + SCREENSHOT_FILE_EXTENSION );
78+ Files .copy (source , destination .toPath (), StandardCopyOption .REPLACE_EXISTING );
7779 // Absolute path to the screenshot file
7880 final Path absoluteFile = destination .toPath ().toAbsolutePath ().normalize ();
7981 // Jenkins JUnit Attachments Plugin resolves [[ATTACHMENT|<path>]] markers against
0 commit comments