From da46c9d2872859786338c458a8c3bd779bd200e4 Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Wed, 11 Dec 2024 09:54:53 -0800 Subject: [PATCH 1/2] Wait a reasonable time for tab to load Log actual readyState when it doesn't --- src/org/labkey/test/WebDriverWrapper.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/org/labkey/test/WebDriverWrapper.java b/src/org/labkey/test/WebDriverWrapper.java index 5b38bc7812..9cf1ad3fdb 100644 --- a/src/org/labkey/test/WebDriverWrapper.java +++ b/src/org/labkey/test/WebDriverWrapper.java @@ -22,6 +22,7 @@ import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; +import org.awaitility.Awaitility; import org.eclipse.jetty.util.URIUtil; import org.intellij.lang.annotations.Language; import org.jetbrains.annotations.Contract; @@ -1006,9 +1007,8 @@ public void switchToWindow(int index) try { getDriver().switchTo().window(windows.get(index)); - new WebDriverWait(getDriver(), Duration.ofSeconds(WAIT_FOR_PAGE)) - .withMessage("waiting for document to be ready") - .until(wd -> Objects.equals(executeScript("return document.readyState;"), "complete")); + Awaitility.await("waiting for document to be ready").atMost(Duration.ofMillis(WAIT_FOR_PAGE)).untilAsserted(() -> + assertEquals("document.readyState", "complete", executeScript("return document.readyState;"))); } catch (StackOverflowError soe) { From 2c9dfccbdba984e28f0468082b6853411f0f61ba Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Wed, 11 Dec 2024 14:44:09 -0800 Subject: [PATCH 2/2] Accept odd readyState --- src/org/labkey/test/WebDriverWrapper.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/org/labkey/test/WebDriverWrapper.java b/src/org/labkey/test/WebDriverWrapper.java index 9cf1ad3fdb..8725f3c9fc 100644 --- a/src/org/labkey/test/WebDriverWrapper.java +++ b/src/org/labkey/test/WebDriverWrapper.java @@ -22,6 +22,7 @@ import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; +import org.assertj.core.api.Assertions; import org.awaitility.Awaitility; import org.eclipse.jetty.util.URIUtil; import org.intellij.lang.annotations.Language; @@ -1008,7 +1009,8 @@ public void switchToWindow(int index) { getDriver().switchTo().window(windows.get(index)); Awaitility.await("waiting for document to be ready").atMost(Duration.ofMillis(WAIT_FOR_PAGE)).untilAsserted(() -> - assertEquals("document.readyState", "complete", executeScript("return document.readyState;"))); + Assertions.assertThat(executeScript("return document.readyState;")) + .as("document.readyState").isIn("complete", "uninitialized")); // "uninitialized" for blank firefox tab } catch (StackOverflowError soe) {