From 02fbe3954a105d0c28b1e306a42beee7f8a1357c Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Fri, 16 Feb 2024 11:56:10 -0800 Subject: [PATCH 1/3] Change number of expected grid filters. Change check that a grid filter has been removed. --- .../test/components/ui/FilterStatusValue.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/org/labkey/test/components/ui/FilterStatusValue.java b/src/org/labkey/test/components/ui/FilterStatusValue.java index 4b4c0557c3..dcc6d70bd3 100644 --- a/src/org/labkey/test/components/ui/FilterStatusValue.java +++ b/src/org/labkey/test/components/ui/FilterStatusValue.java @@ -4,9 +4,9 @@ import org.labkey.test.WebDriverWrapper; import org.labkey.test.components.Component; import org.labkey.test.components.WebDriverComponent; +import org.openqa.selenium.StaleElementReferenceException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedConditions; public class FilterStatusValue extends WebDriverComponent { @@ -52,16 +52,23 @@ public void remove() getWrapper().mouseOver(getComponentElement()); getWrapper().mouseOver(elementCache().icon); WebDriverWrapper.waitFor(()-> isActive() && isClose(), - "the filter status item with text ["+getText()+"] did not become active", 500); + "The filter status item with text ["+getText()+"] did not become active.", 500); elementCache().icon.click(); - // if the item you're dismissing is not the rightmost, it won't become stale; instead, its text will + // If the item you're dismissing is not the rightmost, it won't become stale; instead, its text will // be swapped out with the one to its right. So, we check to see that either the text has changed or // the item became stale. - WebDriverWrapper.waitFor(()-> { - return ExpectedConditions.stalenessOf(getComponentElement()).apply(getDriver()) - || !getText().equals(originalText); - }, "the value item ["+originalText+"] did not disappear", 1000); + WebDriverWrapper.waitFor(()-> { + try + { + return !getText().equals(originalText); + } + catch (StaleElementReferenceException s) + { + return true; + } + } + , "The value item ["+originalText+"] did not disappear.", 1000); } /** From bec086d54bf227b9f8e83e2dac35aa3171c0dcdd Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Mon, 19 Feb 2024 07:06:21 -0800 Subject: [PATCH 2/3] Update check for grid filter to use expected condition. --- .../test/components/ui/FilterStatusValue.java | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/org/labkey/test/components/ui/FilterStatusValue.java b/src/org/labkey/test/components/ui/FilterStatusValue.java index dcc6d70bd3..62282b2eea 100644 --- a/src/org/labkey/test/components/ui/FilterStatusValue.java +++ b/src/org/labkey/test/components/ui/FilterStatusValue.java @@ -4,9 +4,9 @@ import org.labkey.test.WebDriverWrapper; import org.labkey.test.components.Component; import org.labkey.test.components.WebDriverComponent; -import org.openqa.selenium.StaleElementReferenceException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.ExpectedConditions; public class FilterStatusValue extends WebDriverComponent { @@ -57,17 +57,10 @@ public void remove() // If the item you're dismissing is not the rightmost, it won't become stale; instead, its text will // be swapped out with the one to its right. So, we check to see that either the text has changed or - // the item became stale. - WebDriverWrapper.waitFor(()-> { - try - { - return !getText().equals(originalText); - } - catch (StaleElementReferenceException s) - { - return true; - } - } + // the item became stale. ExpectedConditions.textToBePresentInElement returns false if element is stale. + WebDriverWrapper.waitFor(()-> ExpectedConditions.not( + ExpectedConditions.textToBePresentInElement(elementCache().textSpan(), originalText)) + .apply(getDriver()) , "The value item ["+originalText+"] did not disappear.", 1000); } From 8c82691761dc401a8a0147efdb04aee54cc92675 Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Mon, 19 Feb 2024 07:56:37 -0800 Subject: [PATCH 3/3] Change locator for text on filter pill to be lazily found, and better integrated with ExpectedConditions. --- src/org/labkey/test/components/ui/FilterStatusValue.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/org/labkey/test/components/ui/FilterStatusValue.java b/src/org/labkey/test/components/ui/FilterStatusValue.java index 62282b2eea..34422a9060 100644 --- a/src/org/labkey/test/components/ui/FilterStatusValue.java +++ b/src/org/labkey/test/components/ui/FilterStatusValue.java @@ -33,7 +33,7 @@ public WebDriver getDriver() public String getText() { - return elementCache().textSpan().getText(); + return elementCache().textSpan.getText(); } private boolean isActive() @@ -59,7 +59,7 @@ public void remove() // be swapped out with the one to its right. So, we check to see that either the text has changed or // the item became stale. ExpectedConditions.textToBePresentInElement returns false if element is stale. WebDriverWrapper.waitFor(()-> ExpectedConditions.not( - ExpectedConditions.textToBePresentInElement(elementCache().textSpan(), originalText)) + ExpectedConditions.textToBePresentInElement(elementCache().textSpan, originalText)) .apply(getDriver()) , "The value item ["+originalText+"] did not disappear.", 1000); } @@ -82,10 +82,7 @@ protected ElementCache newElementCache() protected class ElementCache extends Component.ElementCache { - public WebElement textSpan() - { - return Locator.tag("span").findElement(getComponentElement()); - } + public final WebElement textSpan = Locator.tag("span").refindWhenNeeded(getComponentElement()); public final WebElement icon = Locator.tag("i").findWhenNeeded(getComponentElement()); }