Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for readyState when switching test windows #2191

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading