[java-idp-integration-tests] 01/02: Support testing Chrome locally

Tom Zeller tzeller at dragonacea.biz
Tue Aug 30 17:37:01 UTC 2022


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=5f4971dc15f31c6cf80b4e16e91baa3aabded12a

commit 5f4971dc15f31c6cf80b4e16e91baa3aabded12a
Author: Tom Zeller <tzeller at dragonacea.biz>
AuthorDate: Mon Aug 29 22:29:40 2022 -0500

    Support testing Chrome locally
---
 .../idp/integration/tests/BaseIntegrationTest.java | 26 ++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/src/test/java/net/shibboleth/idp/integration/tests/BaseIntegrationTest.java b/src/test/java/net/shibboleth/idp/integration/tests/BaseIntegrationTest.java
index ce69065..5477f21 100644
--- a/src/test/java/net/shibboleth/idp/integration/tests/BaseIntegrationTest.java
+++ b/src/test/java/net/shibboleth/idp/integration/tests/BaseIntegrationTest.java
@@ -85,6 +85,8 @@ import org.openqa.selenium.Point;
 import org.openqa.selenium.StaleElementReferenceException;
 import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.openqa.selenium.chrome.ChromeOptions;
 import org.openqa.selenium.firefox.FirefoxDriver;
 import org.openqa.selenium.firefox.FirefoxOptions;
 import org.openqa.selenium.interactions.Actions;
@@ -1070,7 +1072,7 @@ public abstract class BaseIntegrationTest {
      * 
      * If test is local and 'SELENIUM_BROWSER' system property is 'safari', start a Safari web driver.
      * 
-     * If test is local and 'SELENIUM_BROWSER' system property is 'chrome', throw an IllegalArgumentException.
+     * If test is local and 'SELENIUM_BROWSER' system property is 'chrome', start a Chrome web driver.
      * 
      * Otherwise, start a Firefox web driver.
      * 
@@ -1080,7 +1082,6 @@ public abstract class BaseIntegrationTest {
      * 
      * @param browserData the platform+browser+version triplet
      * 
-     * @throws IllegalArgumentException if browser is chrome
      * @throws Exception if an error occurs
      */
     public void startSeleniumClient(@Nullable final BrowserData browserData) throws Exception {
@@ -1089,7 +1090,8 @@ public abstract class BaseIntegrationTest {
             final DesiredCapabilities desiredCapabilities = setUpDesiredCapabilities(browserData);
             setUpSauceDriver(desiredCapabilities);
         } else if (browserData.getBrowser().equalsIgnoreCase("chrome")) {
-            throw new IllegalArgumentException("Chrome web driver not supported");
+            log.debug("Setting up local Chrome web driver");
+            setUpChromeDriver();
         } else if (browserData.getBrowser().equalsIgnoreCase("safari")) {
             log.debug("Setting up local Safari web driver");
             setUpSafariDriver();
@@ -1562,12 +1564,28 @@ public abstract class BaseIntegrationTest {
         testName = method.getDeclaringClass().getName() + "." + method.getName();
     }
 
+    /**
+     * Set up Chrome web driver.
+     * 
+     * @throws IOException ...
+     */
+    public void setUpChromeDriver() throws IOException {
+        final ChromeOptions options = new ChromeOptions();
+        options.setAcceptInsecureCerts(true);
+        options.setHeadless(true);
+        if (Boolean.getBoolean("no-headless")) {
+            options.setHeadless(false);
+        }
+        driver = new ChromeDriver(options);
+        driver.manage().window().setPosition(new Point(0, 0));
+        driver.manage().window().setSize(new Dimension(1024, 768));
+    }
+
     /**
      * Set up Firefox web driver.
      * 
      * @throws IOException ...
      */
-    @BeforeMethod(enabled = false)
     public void setUpFirefoxDriver() throws IOException {
         final FirefoxOptions options = new FirefoxOptions();
         options.setAcceptInsecureCerts(true);

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


More information about the commits mailing list