[java-idp-integration-tests] 01/04: Add screenshot helper method

Tom Zeller tzeller at dragonacea.biz
Thu Sep 11 12:41:05 UTC 2025


This is an automated email from the git hooks/post-receive script.

tzeller pushed a commit to branch main
in repository java-idp-integration-tests.

View the commit online:
http://git.shibboleth.net/view/?p=java-idp-integration-tests.git;a=commit;h=ef4de8aecc31b7f6fbb396301da6cf040ea8aff4

commit ef4de8aecc31b7f6fbb396301da6cf040ea8aff4
Author: Tom Zeller <tzeller at dragonacea.biz>
AuthorDate: Wed Sep 10 18:00:04 2025 -0500

    Add screenshot helper method
---
 .../net/shibboleth/idp/integration/tests/BaseTest.java  | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/test/java/net/shibboleth/idp/integration/tests/BaseTest.java b/src/test/java/net/shibboleth/idp/integration/tests/BaseTest.java
index ed1b7dd..6f4f06c 100644
--- a/src/test/java/net/shibboleth/idp/integration/tests/BaseTest.java
+++ b/src/test/java/net/shibboleth/idp/integration/tests/BaseTest.java
@@ -74,8 +74,10 @@ import org.openqa.selenium.By;
 import org.openqa.selenium.Dimension;
 import org.openqa.selenium.ElementNotInteractableException;
 import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.OutputType;
 import org.openqa.selenium.Point;
 import org.openqa.selenium.StaleElementReferenceException;
+import org.openqa.selenium.TakesScreenshot;
 import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.WebDriverException;
 import org.openqa.selenium.WebElement;
@@ -3633,4 +3635,19 @@ public abstract class BaseTest {
         setUpLocalDynamicMetadataProvider();
     }
 
+    /**
+     * Take a screenshot and save in per-test directory.
+     * 
+     * @param pathToScreenshot
+     *            screenshot file name
+     */
+    public void screenshot(@Nonnull final String pathToScreenshot) {
+        try {
+            final File tmpFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
+            Files.copy(tmpFile.toPath(), pathToPerTestDirectory.resolve(pathToScreenshot));
+        } catch (final IOException e) {
+            log.error("Unable to take screenshot {}", pathToScreenshot, e);
+        }
+    }
+
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list