[java-idp-integration-tests] branch main updated: Stale element exception workaround when using Safari

Tom Zeller tzeller at dragonacea.biz
Fri Jun 25 01:08:34 UTC 2021


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=80054cee60d44eb08358af9cd8a0859422b1a918

The following commit(s) were added to refs/heads/main by this push:
       new  80054ce   Stale element exception workaround when using Safari
80054ce is described below

commit 80054cee60d44eb08358af9cd8a0859422b1a918
Author: Tom Zeller <tzeller at dragonacea.biz>
AuthorDate: Thu Jun 24 20:08:18 2021 -0500

    Stale element exception workaround when using Safari
    
    Catch exception and try again
---
 .../shibboleth/idp/test/BaseIntegrationTest.java   | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java b/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java
index 9ebfe3a..57d4f95 100644
--- a/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java
+++ b/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java
@@ -72,6 +72,7 @@ import org.openqa.selenium.By;
 import org.openqa.selenium.Dimension;
 import org.openqa.selenium.Platform;
 import org.openqa.selenium.Point;
+import org.openqa.selenium.StaleElementReferenceException;
 import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.WebElement;
 import org.openqa.selenium.firefox.FirefoxDriver;
@@ -1988,15 +1989,26 @@ public abstract class BaseIntegrationTest
     /**
      * Wait for page whose body has text that starts with the given text.
      * 
+     * Attempts to workaround {@link StaleElementReferenceException} by retrieving the body text a second time.
+     * 
      * @param prefix the prefix of the page body text
      */
     public void waitForPageBodyStartsWith(@Nonnull final String prefix) {
         Assert.assertNotNull(prefix);
-        (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
-            public Boolean apply(WebDriver d) {
-                return d.findElement(By.tagName("body")).getText().startsWith(prefix);
-            }
-        });
+        try {
+            (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
+                public Boolean apply(WebDriver d) {
+                    return d.findElement(By.tagName("body")).getText().startsWith(prefix);
+                }
+            });
+        } catch (final StaleElementReferenceException e) {
+            log.debug("Caught StaleElementReferenceException, will try again...", e);
+            (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
+                public Boolean apply(WebDriver d) {
+                    return d.findElement(By.tagName("body")).getText().startsWith(prefix);
+                }
+            });
+        }
     }
 
     /**

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


More information about the commits mailing list