From 57d8b6c4df62eeeb219fe874bf53c3acb3743734 Mon Sep 17 00:00:00 2001 From: Trey Chadick Date: Wed, 2 Oct 2024 10:35:39 -0700 Subject: [PATCH] Wait for combo box options to be filtered (#31) --- test/src/org/labkey/test/tests/reagent/ReagentTest.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/src/org/labkey/test/tests/reagent/ReagentTest.java b/test/src/org/labkey/test/tests/reagent/ReagentTest.java index 21fe758..c5372c3 100644 --- a/test/src/org/labkey/test/tests/reagent/ReagentTest.java +++ b/test/src/org/labkey/test/tests/reagent/ReagentTest.java @@ -15,6 +15,7 @@ */ package org.labkey.test.tests.reagent; +import org.awaitility.Awaitility; import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -32,6 +33,7 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; +import java.time.Duration; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -111,8 +113,10 @@ public void testInsert() click(Locator.xpath("//input[@name='LabelId']/../img")); setFormElement(Locator.xpath("//input[@name='LabelId']/../input[contains(@class, 'x-form-field')]"), "Alexa"); - int alexaLabels = getElementCount(Locator.tag("div").withClass("x-combo-list-item").notHidden().containing("Alexa")); - assertEquals("Expected to find 5 Alexa labels", 5, alexaLabels); + Locator locator = Locator.tag("div").withClass("x-combo-list-item").notHidden().containing("Alexa"); + // Wait for combo box to be filtered + Awaitility.await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> + assertEquals("Expected to find 5 Alexa labels", 5, locator.findElements(getDriver()).size())); Actions builder = new Actions(getDriver()); builder.sendKeys(Keys.ARROW_DOWN, Keys.ARROW_DOWN).build().perform();