Skip to content

Commit

Permalink
Wait for readyState when switching test windows (#2191)
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-tchad authored Dec 12, 2024
1 parent e02cdff commit 75d9e34
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/org/labkey/test/WebDriverWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
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;
import org.jetbrains.annotations.Contract;
Expand Down Expand Up @@ -1006,9 +1008,9 @@ 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(() ->
Assertions.assertThat(executeScript("return document.readyState;"))
.as("document.readyState").isIn("complete", "uninitialized")); // "uninitialized" for blank firefox tab
}
catch (StackOverflowError soe)
{
Expand Down

0 comments on commit 75d9e34

Please sign in to comment.