Skip to content
Merged
Show file tree
Hide file tree
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
24 changes: 24 additions & 0 deletions src/org/labkey/test/WebDriverWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import org.openqa.selenium.Keys;
import org.openqa.selenium.NoAlertPresentException;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.NoSuchWindowException;
import org.openqa.selenium.ScriptTimeoutException;
import org.openqa.selenium.SearchContext;
import org.openqa.selenium.StaleElementReferenceException;
Expand Down Expand Up @@ -2132,6 +2133,29 @@ public long doAndMaybeWaitForPageToLoad(int msWait, Supplier<Boolean> action)
return loadTimer.elapsed().toMillis();
}

public long doAndWaitForWindow(Runnable action, String windowName)
{
return doAndMaybeWaitForPageToLoad(10_000, () -> {
String initialWindow = getDriver().getWindowHandle();
boolean targetWindowExists;
try
{
getDriver().switchTo().window(windowName);
getDriver().switchTo().window(initialWindow);
targetWindowExists = true;
}
catch (NoSuchWindowException e)
{
targetWindowExists = false;
}

action.run();

getDriver().switchTo().window(windowName);
return targetWindowExists;
});
}

public long doAndAcceptUnloadAlert(Runnable func, String partialAlertText)
{
return doAndWaitForPageToLoad(() ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ public static ConfigureSystemMaintenancePage beginAt(WebDriverWrapper webDriverW
*/
public PipelineStatusDetailsPage runMaintenanceTask(String description)
{
click(Locator.tagWithAttribute("input", "type", "checkbox")
.followingSibling("a").withText(description));
getDriver().switchTo().window("systemMaintenance");
doAndWaitForWindow(() -> click(Locator.tagWithAttribute("input", "type", "checkbox")
.followingSibling("a").withText(description)), "systemMaintenance");

PipelineStatusDetailsPage pipelineStatusDetailsPage = new PipelineStatusDetailsPage(getDriver());
pipelineStatusDetailsPage.waitForComplete();
Expand Down