From dea0032a9edb721b4fed52617dd6b0d8489143de Mon Sep 17 00:00:00 2001 From: Dan Duffek Date: Thu, 28 Dec 2023 13:10:02 -0800 Subject: [PATCH] Test Automation Fixes for Shared Components (#1765) --- .../test/components/domain/DomainPanel.java | 9 ++++-- .../ui/DeleteConfirmationDialog.java | 30 +++++++++++++++++-- .../ui/entities/ParentEntityEditPanel.java | 8 +++-- .../ui/grids/CustomizeGridViewDialog.java | 17 +++++++++-- .../components/ui/pipeline/ImportsPage.java | 2 +- .../components/ui/pipeline/StatusPage.java | 3 +- 6 files changed, 57 insertions(+), 12 deletions(-) diff --git a/src/org/labkey/test/components/domain/DomainPanel.java b/src/org/labkey/test/components/domain/DomainPanel.java index 43b6271cfe..62b9e3aba0 100644 --- a/src/org/labkey/test/components/domain/DomainPanel.java +++ b/src/org/labkey/test/components/domain/DomainPanel.java @@ -1,11 +1,13 @@ package org.labkey.test.components.domain; +import org.labkey.test.BootstrapLocators; import org.labkey.test.Locator; import org.labkey.test.components.Component; import org.labkey.test.components.WebDriverComponent; import org.labkey.test.util.LabKeyExpectedConditions; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.ExpectedConditions; import java.util.Optional; @@ -62,8 +64,11 @@ protected T setExpanded(boolean expand) { elementCache().expandToggle.click(); waitFor(() -> isExpanded() == expand, "Panel failed to " + (expand ? "expand" : "collapse"), 2_000); - getWrapper().shortWait() - .until(LabKeyExpectedConditions.animationIsDone(elementCache().panelBody)); // wait for transition to happen + + // wait for transition to happen and no spinners to be present + getWrapper().longWait() + .until(ExpectedConditions.and(LabKeyExpectedConditions.animationIsDone(elementCache().panelBody), + ExpectedConditions.numberOfElementsToBe(BootstrapLocators.loadingSpinner, 0))); } return getThis(); } diff --git a/src/org/labkey/test/components/ui/DeleteConfirmationDialog.java b/src/org/labkey/test/components/ui/DeleteConfirmationDialog.java index d832d8eb3f..ef8e8f9918 100644 --- a/src/org/labkey/test/components/ui/DeleteConfirmationDialog.java +++ b/src/org/labkey/test/components/ui/DeleteConfirmationDialog.java @@ -82,9 +82,33 @@ public SourcePage clickDismiss() public DeleteConfirmationDialog setUserComment(String comment) { - var commentInput = Input.Input(Locator.tagWithClass("textarea", "form-control"), getDriver()).timeout(2000) - .refindWhenNeeded(this); - commentInput.set(comment); + + WebDriverWrapper.waitFor(()-> elementCache().commentInput.getComponentElement().isDisplayed(), + "The 'Comment' field is not visible.", 2_500); + + elementCache().commentInput.set(comment); return this; } + + @Override + protected ElementCache newElementCache() + { + return new ElementCache(); + } + + @Override + protected ElementCache elementCache() + { + return (ElementCache) super.elementCache(); + } + + protected class ElementCache extends ModalDialog.ElementCache + { + + Input commentInput = Input.Input(Locator.tagWithClass("textarea", "form-control"), getDriver()).timeout(2000) + .refindWhenNeeded(this); + + } + + } diff --git a/src/org/labkey/test/components/ui/entities/ParentEntityEditPanel.java b/src/org/labkey/test/components/ui/entities/ParentEntityEditPanel.java index 77ed79a816..8454da1716 100644 --- a/src/org/labkey/test/components/ui/entities/ParentEntityEditPanel.java +++ b/src/org/labkey/test/components/ui/entities/ParentEntityEditPanel.java @@ -140,7 +140,10 @@ private void clickButtonWaitForPanel(WebElement button, int wait) infoCount <= 1); // A reference to the editing header title - WebElement editorHeading = Locator.tagWithClass("div", "panel-heading").startsWith("Editing").findWhenNeeded(getDriver()); + Locator editingLocator = Locator.tagWithClass("div", "panel-heading").startsWith("Editing"); + + Assert.assertEquals("Cannot find a panel with 'Editing' in the header. There isn't a panel in edit mode.", + 1, editingLocator.findElements(getDriver()).size()); // Shouldn't need to do this, but when tests fail, because the panel did not exit edit mode, the button is not in view. getWrapper().scrollIntoView(button); @@ -153,7 +156,8 @@ private void clickButtonWaitForPanel(WebElement button, int wait) // Wait until the counts of panels not in edit mode increases and the editor heading is no longer visible. WebDriverWrapper.waitFor(()-> - (defaultPanel.findElements(getDriver()).size() > defaultCount) && !editorHeading.isDisplayed(), + defaultPanel.findElements(getDriver()).size() > defaultCount && + editingLocator.findElements(getDriver()).isEmpty(), "Panel did not change state.", wait); } diff --git a/src/org/labkey/test/components/ui/grids/CustomizeGridViewDialog.java b/src/org/labkey/test/components/ui/grids/CustomizeGridViewDialog.java index 4333bd034b..55b04eb426 100644 --- a/src/org/labkey/test/components/ui/grids/CustomizeGridViewDialog.java +++ b/src/org/labkey/test/components/ui/grids/CustomizeGridViewDialog.java @@ -11,6 +11,7 @@ import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import java.time.Duration; @@ -316,11 +317,21 @@ public CustomizeGridViewDialog removeColumn(String column) public CustomizeGridViewDialog removeColumn(String column, int index) { WebElement listItem = getShownInGridListItems(column).get(index); - WebElement removeIcon = Locator.tagWithClass("span", "view-field__action").findWhenNeeded(listItem); + + // Make sure the mouse is on the identified row. Tests that remove columns one after another can show the mouse + // hovering for a moment over the remove icon of the previous row. + listItem.click(); + + WebElement removeIcon = Locator.tagWithClass("span", "view-field__action").findElement(listItem); + getWrapper().mouseOver(removeIcon); removeIcon.click(); - WebDriverWrapper.waitFor(()->!removeIcon.isDisplayed(), - String.format("Column '%s' was not removed from list.", column), 500); + // Move the mouse over the dialog title. + getWrapper().mouseOver(Locator.tagWithClass("h4", "modal-title").findElement(this)); + + getWrapper().shortWait() + .withMessage(String.format("Column '%s' was not removed from list.", column)) + .until(ExpectedConditions.stalenessOf(listItem)); return this; } diff --git a/src/org/labkey/test/components/ui/pipeline/ImportsPage.java b/src/org/labkey/test/components/ui/pipeline/ImportsPage.java index c5dd58a5e5..8e51c241e6 100644 --- a/src/org/labkey/test/components/ui/pipeline/ImportsPage.java +++ b/src/org/labkey/test/components/ui/pipeline/ImportsPage.java @@ -34,7 +34,7 @@ protected void waitForPage() } }, "The 'Background Imports' page did not load in time.", - 2_500); + 15_000); } public static ImportsPage beginAt(WebDriverWrapper webDriverWrapper, String containerPath) diff --git a/src/org/labkey/test/components/ui/pipeline/StatusPage.java b/src/org/labkey/test/components/ui/pipeline/StatusPage.java index 39a59f2309..80ca7ef5f4 100644 --- a/src/org/labkey/test/components/ui/pipeline/StatusPage.java +++ b/src/org/labkey/test/components/ui/pipeline/StatusPage.java @@ -6,6 +6,7 @@ import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.StaleElementReferenceException; import org.openqa.selenium.WebElement; + import java.util.HashMap; import java.util.List; import java.util.Map; @@ -34,7 +35,7 @@ protected void waitForPage() } }, "The 'Pipeline Status' page did not load in time.", - 2_500); + 5_000); } public String getPageHeader()