From 918d3269d1c4c036240de45cbe2d870eacd39d4a Mon Sep 17 00:00:00 2001 From: edalex-yinzi <92769668+edalex-yinzi@users.noreply.github.com> Date: Tue, 20 Feb 2024 13:37:03 +1100 Subject: [PATCH] fix: FavouritesPowerSearchIntegration (#5008) --- .../pageobject/searching/AbstractResultList.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/searching/AbstractResultList.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/searching/AbstractResultList.java index 072c97c503..473e5dea22 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/searching/AbstractResultList.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/searching/AbstractResultList.java @@ -10,6 +10,7 @@ import java.util.List; import org.openqa.selenium.By; import org.openqa.selenium.SearchContext; +import org.openqa.selenium.TimeoutException; import org.openqa.selenium.WebElement; import org.openqa.selenium.internal.WrapsElement; import org.openqa.selenium.support.ui.ExpectedConditions; @@ -87,8 +88,9 @@ public List getResults() { List results = new ArrayList(); if (isResultsAvailable()) { - int count = - getResultsDiv().findElements(By.xpath("//div[@class='itemresult-wrapper']")).size(); + By items = By.xpath("//div[@class='itemresult-wrapper']"); + waiter.until(ExpectedConditions.presenceOfAllElementsLocatedBy(items)); + int count = getResultsDiv().findElements(items).size(); for (int i = 1; i <= count; i++) { results.add(getResult(i)); @@ -122,6 +124,7 @@ public boolean doesResultExist(PrefixedName title) { public boolean doesResultExist(String title) { boolean found = false; int size = getResults().size(); + for (int i = 1; i <= size; i++) { found = doesResultExist(title, i); if (found) { @@ -132,6 +135,13 @@ public boolean doesResultExist(String title) { } public boolean isResultsAvailable() { - return isPresent(By.xpath("//div[@class='itemresult-wrapper']")); + try { + waiter.until( + ExpectedConditions.presenceOfElementLocated( + By.xpath("//div[@class='itemresult-wrapper']"))); + return true; + } catch (TimeoutException Time) { + return false; + } } }