From 7ab381f88141291ccfd07357e4f514af67b805a1 Mon Sep 17 00:00:00 2001 From: Ian Stevenson Date: Thu, 30 Jan 2025 12:01:26 +1100 Subject: [PATCH 01/11] chore: upgrade to Selenium 4.x Reapply "Merge pull request #3522 from openequella/renovate/org.seleniumhq.selenium-selenium-java-4.x" This reverts commit eca283e0692952a7ab7d6e44b032bbbd21f493c5. --- .../asc/AdvancedScriptControlTests.java | 7 ++++--- .../rest/NotificationsApiTest.java | 4 +++- autotest/Tests/build.sbt | 2 +- .../framework/StandardDriverFactory.java | 3 --- .../tle/webtests/framework/TestConfig.java | 5 +++-- .../factory/RefreshingElementHandler.java | 8 ++++---- .../factory/RefreshingFieldDecorator.java | 2 +- .../framework/setup/SyncToLocalServer.java | 3 --- .../tle/webtests/pageobject/AbstractPage.java | 20 ++++++++++++++----- .../pageobject/ExpectedConditions2.java | 2 +- .../pageobject/cal/CALOverridePage.java | 3 ++- .../EditBlackboardConnectorPage.java | 4 +++- .../pageobject/institution/DatabaseRow.java | 3 ++- .../pageobject/institution/ImportTab.java | 3 ++- .../institution/MigrationProgressDialog.java | 3 ++- .../pageobject/institution/StatusPage.java | 3 ++- .../integration/moodle/MoodleBasePage.java | 9 ++++++--- .../migration/UpgradeStepsPage.java | 3 ++- .../sru/RemoteRepoSRUSearchPage.java | 4 +++- .../reporting/AbstractReportWindow.java | 4 ++-- .../searching/AbstractResultList.java | 2 +- .../searching/AutoCompleteOptions.java | 5 ++++- .../pageobject/searching/BulkResultsPage.java | 3 ++- .../pageobject/settings/MailSettingsPage.java | 4 +++- .../controls/AutoCompleteTermControl.java | 5 ++++- .../KalturaUniversalControlType.java | 3 ++- .../universal/iTunesUniversalControlType.java | 3 ++- .../browserpage/BrowserPage.scala | 5 +++-- 28 files changed, 79 insertions(+), 46 deletions(-) diff --git a/autotest/OldTests/src/test/java/com/tle/webtests/test/contribute/controls/asc/AdvancedScriptControlTests.java b/autotest/OldTests/src/test/java/com/tle/webtests/test/contribute/controls/asc/AdvancedScriptControlTests.java index 68bdb3bcb91..78972128a62 100644 --- a/autotest/OldTests/src/test/java/com/tle/webtests/test/contribute/controls/asc/AdvancedScriptControlTests.java +++ b/autotest/OldTests/src/test/java/com/tle/webtests/test/contribute/controls/asc/AdvancedScriptControlTests.java @@ -32,6 +32,7 @@ import java.net.MalformedURLException; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.time.Duration; import java.util.Date; import java.util.List; import java.util.Random; @@ -1068,7 +1069,7 @@ private List getDivsByPrefix(String prefix) { */ private WebElement getAscMessage() { By ascMessageXpath = By.xpath("//div[@id='ascMessage']/span"); - WebDriverWait wait = new WebDriverWait(context.getDriver(), 30); + WebDriverWait wait = new WebDriverWait(context.getDriver(), Duration.ofSeconds(30)); wait.until(ExpectedConditions.visibilityOfElementLocated(ascMessageXpath)); return context.getDriver().findElement(ascMessageXpath); } @@ -1087,7 +1088,7 @@ private String getDivMessageForId(String id) { private void ascEditbox(int ctrlNum, String suffix, String text) { WebElement field = context.getDriver().findElement(By.name("c" + ctrlNum + suffix)); - WebDriverWait wait = new WebDriverWait(context.getDriver(), 30); + WebDriverWait wait = new WebDriverWait(context.getDriver(), Duration.ofSeconds(30)); wait.until(ExpectedConditions.visibilityOf(field)); field.clear(); field.sendKeys(text); @@ -1100,7 +1101,7 @@ private void ascEditbox(int ctrlNum, String suffix, String text) { * @param text */ private void ascSelectDropdown(String id, String optText) { - WebDriverWait wait = new WebDriverWait(context.getDriver(), 30); + WebDriverWait wait = new WebDriverWait(context.getDriver(), Duration.ofSeconds(30)); wait.until(ExpectedConditions.presenceOfElementLocated(By.id(id))); Select dropdown = new Select(context.getDriver().findElement(By.id(id))); dropdown.selectByVisibleText(optText); diff --git a/autotest/OldTests/src/test/java/com/tle/webtests/test/webservices/rest/NotificationsApiTest.java b/autotest/OldTests/src/test/java/com/tle/webtests/test/webservices/rest/NotificationsApiTest.java index a488e8d415e..b5ef1a0e795 100644 --- a/autotest/OldTests/src/test/java/com/tle/webtests/test/webservices/rest/NotificationsApiTest.java +++ b/autotest/OldTests/src/test/java/com/tle/webtests/test/webservices/rest/NotificationsApiTest.java @@ -19,6 +19,7 @@ import com.tle.webtests.pageobject.wizard.WizardPageTab; import com.tle.webtests.test.AbstractCleanupTest; import java.io.IOException; +import java.time.Duration; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -68,7 +69,8 @@ public void notificationsSubsearchTest() throws Exception { private void waitForIndex() throws IOException { final String token = requestToken(OAUTH_CLIENT_ID); - WebDriverWait notificationsIndexedWaiter = new WebDriverWait(context.getDriver(), 10); + WebDriverWait notificationsIndexedWaiter = + new WebDriverWait(context.getDriver(), Duration.ofSeconds(10)); notificationsIndexedWaiter.until( (Function) driver -> { diff --git a/autotest/Tests/build.sbt b/autotest/Tests/build.sbt index 8581573e8e7..7266b854db2 100644 --- a/autotest/Tests/build.sbt +++ b/autotest/Tests/build.sbt @@ -23,7 +23,7 @@ libraryDependencies ++= Seq( "org.scala-lang" % "scala-reflect" % scalaVersion.value, "javax.jws" % "javax.jws-api" % "1.1", "org.apache.commons" % "commons-lang3" % "3.14.0", - "org.seleniumhq.selenium" % "selenium-java" % "3.141.59", + "org.seleniumhq.selenium" % "selenium-java" % "4.26.0", "org.easytesting" % "fest-util" % "1.2.5", "org.easytesting" % "fest-swing" % "1.2.1", "xalan" % "xalan" % "2.7.3", diff --git a/autotest/Tests/src/main/java/com/tle/webtests/framework/StandardDriverFactory.java b/autotest/Tests/src/main/java/com/tle/webtests/framework/StandardDriverFactory.java index 5456ec26bf9..3a6fa4d2c1b 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/framework/StandardDriverFactory.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/framework/StandardDriverFactory.java @@ -1,7 +1,5 @@ package com.tle.webtests.framework; -import static java.util.concurrent.TimeUnit.SECONDS; - import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.Maps; import com.tle.common.Check; @@ -142,7 +140,6 @@ public WebDriver getDriver(Class clazz) throws IOException { } else { binary = new FirefoxBinary(); } - binary.setTimeout(SECONDS.toMillis(120)); FirefoxProfile profile = new FirefoxProfile(); profile.addExtension(getClass(), "firebug-1.10.2-fx.xpi"); profile.addExtension(getClass(), "firepath-0.9.7-fx.xpi"); diff --git a/autotest/Tests/src/main/java/com/tle/webtests/framework/TestConfig.java b/autotest/Tests/src/main/java/com/tle/webtests/framework/TestConfig.java index 933c9be8f8e..78d656ddb8f 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/framework/TestConfig.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/framework/TestConfig.java @@ -11,6 +11,7 @@ import java.net.URL; import java.nio.file.Paths; import java.text.MessageFormat; +import java.time.Duration; import java.util.Properties; import java.util.TimeZone; @@ -68,8 +69,8 @@ public static String findInstitutionName(Class clazz) { return inst; } - public int getStandardTimeout() { - return getIntProperty("timeout.standard", 30); + public Duration getStandardTimeout() { + return Duration.ofSeconds(getIntProperty("timeout.standard", 30)); } public String getAdminPassword() { diff --git a/autotest/Tests/src/main/java/com/tle/webtests/framework/factory/RefreshingElementHandler.java b/autotest/Tests/src/main/java/com/tle/webtests/framework/factory/RefreshingElementHandler.java index b3342a7f580..fc688ff248e 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/framework/factory/RefreshingElementHandler.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/framework/factory/RefreshingElementHandler.java @@ -4,19 +4,19 @@ import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.concurrent.TimeUnit; +import java.time.Duration; import org.openqa.selenium.By; import org.openqa.selenium.SearchContext; import org.openqa.selenium.StaleElementReferenceException; import org.openqa.selenium.WebElement; -import org.openqa.selenium.internal.WrapsElement; +import org.openqa.selenium.WrapsElement; import org.openqa.selenium.support.ui.FluentWait; public class RefreshingElementHandler implements InvocationHandler { private static final FluentWait waiter = new FluentWait(Void.class) - .withTimeout(10, TimeUnit.SECONDS) - .pollingEvery(50, TimeUnit.MILLISECONDS); + .withTimeout(Duration.ofSeconds(10)) + .pollingEvery(Duration.ofMillis(50)); private LazyTemplatedElementLocator locator; private RefreshingElementProxyCreator proxyCreator; diff --git a/autotest/Tests/src/main/java/com/tle/webtests/framework/factory/RefreshingFieldDecorator.java b/autotest/Tests/src/main/java/com/tle/webtests/framework/factory/RefreshingFieldDecorator.java index e6b2b49877c..f68cb506073 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/framework/factory/RefreshingFieldDecorator.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/framework/factory/RefreshingFieldDecorator.java @@ -4,7 +4,7 @@ import java.lang.reflect.InvocationHandler; import java.lang.reflect.Proxy; import org.openqa.selenium.WebElement; -import org.openqa.selenium.internal.WrapsElement; +import org.openqa.selenium.WrapsElement; import org.openqa.selenium.support.pagefactory.DefaultFieldDecorator; import org.openqa.selenium.support.pagefactory.ElementLocator; diff --git a/autotest/Tests/src/main/java/com/tle/webtests/framework/setup/SyncToLocalServer.java b/autotest/Tests/src/main/java/com/tle/webtests/framework/setup/SyncToLocalServer.java index 690f0629694..fee6c870b52 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/framework/setup/SyncToLocalServer.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/framework/setup/SyncToLocalServer.java @@ -1,7 +1,5 @@ package com.tle.webtests.framework.setup; -import static java.util.concurrent.TimeUnit.SECONDS; - import com.tle.webtests.framework.Assert; import com.tle.webtests.framework.PageContext; import com.tle.webtests.framework.TestConfig; @@ -175,7 +173,6 @@ private FirefoxDriver getDriver() { } else { binary = new FirefoxBinary(); } - binary.setTimeout(SECONDS.toMillis(120)); FirefoxProfile profile = new FirefoxProfile(); // profile.addExtension(getClass(), "firebug-1.7.3-fx.xpi"); profile.setPreference("extensions.firebug.currentVersion", "999"); diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/AbstractPage.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/AbstractPage.java index 2220423ed52..24ac7f67b47 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/AbstractPage.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/AbstractPage.java @@ -8,6 +8,7 @@ import java.net.URL; import java.net.URLEncoder; import java.nio.file.Paths; +import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -56,23 +57,32 @@ public AbstractPage( loadedElement = null; } - public AbstractPage(PageContext context, By loadedBy, int timeOut) { - this(context, context.getDriver(), loadedBy, timeOut); + /** + * @param timeoutSeconds -1 for default timeout + */ + public AbstractPage(PageContext context, By loadedBy, int timeoutSeconds) { + this(context, context.getDriver(), loadedBy, timeoutSeconds); } public AbstractPage(PageContext context, SearchContext searchContext, By loadedBy) { this(context, searchContext, loadedBy, -1); } - public AbstractPage(PageContext context, SearchContext searchContext, By loadedBy, int timeOut) { + /** + * @param timeoutSeconds -1 for default timeout + */ + public AbstractPage( + PageContext context, SearchContext searchContext, By loadedBy, int timeoutSeconds) { this( context, searchContext, loadedBy, new WebDriverWait( context.getDriver(), - timeOut == -1 ? context.getTestConfig().getStandardTimeout() : timeOut, - 50)); + timeoutSeconds == -1 + ? context.getTestConfig().getStandardTimeout() + : Duration.ofSeconds(timeoutSeconds), + Duration.ofMillis(50))); } public AbstractPage(PageContext context, By loadedBy) { diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/ExpectedConditions2.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/ExpectedConditions2.java index 7d7567f8e3a..01c5c74b024 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/ExpectedConditions2.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/ExpectedConditions2.java @@ -14,7 +14,7 @@ import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.WebElement; -import org.openqa.selenium.internal.WrapsElement; +import org.openqa.selenium.WrapsElement; import org.openqa.selenium.support.ui.ExpectedCondition; import org.openqa.selenium.support.ui.ExpectedConditions; diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/cal/CALOverridePage.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/cal/CALOverridePage.java index ef4efb15c08..03fb48b699e 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/cal/CALOverridePage.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/cal/CALOverridePage.java @@ -2,6 +2,7 @@ import com.tle.webtests.framework.PageContext; import com.tle.webtests.pageobject.AbstractPage; +import java.time.Duration; import java.util.function.Function; import org.openqa.selenium.*; import org.openqa.selenium.support.FindBy; @@ -30,7 +31,7 @@ public void setReason(String reason) { (Function) webDriver -> { try { - new WebDriverWait(webDriver, 1) + new WebDriverWait(webDriver, Duration.ofSeconds(1)) .until(ExpectedConditions.stalenessOf(getContinueButton())); return false; } catch (TimeoutException toe) { diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/connectors/EditBlackboardConnectorPage.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/connectors/EditBlackboardConnectorPage.java index 0fa028c8ed8..353602aea19 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/connectors/EditBlackboardConnectorPage.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/connectors/EditBlackboardConnectorPage.java @@ -1,6 +1,7 @@ package com.tle.webtests.pageobject.connectors; import com.tle.webtests.pageobject.WaitingPageObject; +import java.time.Duration; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -47,7 +48,8 @@ public WebDriverWait getWaiter() { public EditBlackboardConnectorPage(ShowConnectorsPage connectorsPage) { super(connectorsPage); - this.bbWaiter = new WebDriverWait(context.getDriver(), 60, 50); + this.bbWaiter = + new WebDriverWait(context.getDriver(), Duration.ofMinutes(1), Duration.ofMillis(50)); } public EditBlackboardConnectorPage setUrl(String url, String user, String password) { diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/institution/DatabaseRow.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/institution/DatabaseRow.java index 174f8b713ea..a6583062189 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/institution/DatabaseRow.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/institution/DatabaseRow.java @@ -5,6 +5,7 @@ import com.tle.webtests.framework.EBy; import com.tle.webtests.framework.PageContext; import com.tle.webtests.pageobject.AbstractPage; +import java.time.Duration; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; @@ -26,7 +27,7 @@ public DatabaseRow(PageContext context, WebElement rowElement) { super(context); this.rowElement = rowElement; statusElement = rowElement.findElement(By.className("status")); - longWaiter = new WebDriverWait(context.getDriver(), 60); + longWaiter = new WebDriverWait(context.getDriver(), Duration.ofMinutes(1)); } public void initialise() { diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/institution/ImportTab.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/institution/ImportTab.java index 8f9c6397909..4c0ddcbce07 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/institution/ImportTab.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/institution/ImportTab.java @@ -10,6 +10,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.time.Duration; import java.util.zip.ZipOutputStream; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; @@ -55,7 +56,7 @@ private WebElement getPasswordConfirmElem() { public ImportTab(PageContext context) { super(context, "Import institution", "Import new institution"); - waiter = new WebDriverWait(context.getDriver(), 240); + waiter = new WebDriverWait(context.getDriver(), Duration.ofMinutes(4)); } @Override diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/institution/MigrationProgressDialog.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/institution/MigrationProgressDialog.java index a040a54e42d..bf47195f01b 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/institution/MigrationProgressDialog.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/institution/MigrationProgressDialog.java @@ -3,6 +3,7 @@ import com.google.common.base.Function; import com.tle.webtests.framework.PageContext; import com.tle.webtests.pageobject.AbstractPage; +import java.time.Duration; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; @@ -20,7 +21,7 @@ public class MigrationProgressDialog extends AbstractPage tab) { } public StatusPage(PageContext context, WaitingPageObject tab, long timeout) { - super(context, new WebDriverWait(context.getDriver(), timeout)); + super(context, new WebDriverWait(context.getDriver(), Duration.ofSeconds(timeout))); mustBeVisible = false; this.tab = tab; } diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/integration/moodle/MoodleBasePage.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/integration/moodle/MoodleBasePage.java index da4ba8ba59f..e21d8a26594 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/integration/moodle/MoodleBasePage.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/integration/moodle/MoodleBasePage.java @@ -2,6 +2,7 @@ import com.tle.webtests.framework.PageContext; import com.tle.webtests.pageobject.AbstractPage; +import java.time.Duration; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.Point; @@ -39,15 +40,17 @@ public MoodleBasePage(PageContext context, SearchContext searchContext, By loade } public MoodleBasePage( - PageContext context, SearchContext searchContext, By loadedBy, int timeOut) { + PageContext context, SearchContext searchContext, By loadedBy, int timeoutSeconds) { this( context, searchContext, loadedBy, new WebDriverWait( context.getDriver(), - timeOut == -1 ? context.getTestConfig().getStandardTimeout() : timeOut, - 50)); + timeoutSeconds == -1 + ? context.getTestConfig().getStandardTimeout() + : Duration.ofSeconds(timeoutSeconds), + Duration.ofMillis(50))); } public MoodleBasePage(PageContext context, By loadedBy) { diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/migration/UpgradeStepsPage.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/migration/UpgradeStepsPage.java index 702c2c34d99..9f594757d20 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/migration/UpgradeStepsPage.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/migration/UpgradeStepsPage.java @@ -2,6 +2,7 @@ import com.tle.webtests.framework.PageContext; import com.tle.webtests.pageobject.AbstractPage; +import java.time.Duration; import org.openqa.selenium.By; import org.openqa.selenium.StaleElementReferenceException; import org.openqa.selenium.WebDriver; @@ -13,7 +14,7 @@ public class UpgradeStepsPage extends AbstractPage { public UpgradeStepsPage(PageContext context) { super(context, By.id("mp_confirmBackup")); - waiter = new WebDriverWait(driver, 240); + waiter = new WebDriverWait(driver, Duration.ofMinutes(4)); } public void upgrade(String password) { diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/remoterepo/sru/RemoteRepoSRUSearchPage.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/remoterepo/sru/RemoteRepoSRUSearchPage.java index 6648ce12875..e506e5972ed 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/remoterepo/sru/RemoteRepoSRUSearchPage.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/remoterepo/sru/RemoteRepoSRUSearchPage.java @@ -5,6 +5,7 @@ import com.tle.webtests.pageobject.remoterepo.AbstractRemoteRepoSearchPage; import com.tle.webtests.pageobject.remoterepo.RemoteRepoListPage; import com.tle.webtests.pageobject.remoterepo.RemoteRepoSearchResult; +import java.time.Duration; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.ui.WebDriverWait; @@ -26,7 +27,8 @@ public class RemoteRepoSRUSearchPage public RemoteRepoSRUSearchPage(PageContext context) { super(context); - this.waiter = new WebDriverWait(context.getDriver(), 60, 50); + this.waiter = + new WebDriverWait(context.getDriver(), Duration.ofMinutes(1), Duration.ofMillis(50)); } @Override diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/reporting/AbstractReportWindow.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/reporting/AbstractReportWindow.java index 0f91bd26d3d..db8069eb38e 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/reporting/AbstractReportWindow.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/reporting/AbstractReportWindow.java @@ -4,7 +4,7 @@ import com.tle.webtests.pageobject.AbstractPage; import com.tle.webtests.pageobject.AbstractReport; import com.tle.webtests.pageobject.ExpectWaiter; -import java.util.concurrent.TimeUnit; +import java.time.Duration; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -39,7 +39,7 @@ public void close() { } public R getReport() { - report.getWaiter().withTimeout(5, TimeUnit.MINUTES); + report.getWaiter().withTimeout(Duration.ofMinutes(5)); return ExpectWaiter.waiter( ExpectedConditions.frameToBeAvailableAndSwitchToIt("reportFrame"), report) .get(); 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 ca72a99cdf8..8326c8ceaac 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 @@ -12,7 +12,7 @@ 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.WrapsElement; import org.openqa.selenium.support.ui.ExpectedConditions; public abstract class AbstractResultList< diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/searching/AutoCompleteOptions.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/searching/AutoCompleteOptions.java index 058ba7d53d6..9e52b309a27 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/searching/AutoCompleteOptions.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/searching/AutoCompleteOptions.java @@ -4,6 +4,7 @@ import com.tle.common.Check; import com.tle.webtests.pageobject.AbstractPage; import com.tle.webtests.pageobject.ExpectedConditions2; +import java.time.Duration; import java.util.List; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; @@ -33,7 +34,9 @@ public AutoCompleteOptions(AbstractQuerySection qs) { super(qs.getContext(), LIST_BY); setMustBeVisible(true); this.qs = qs; - acWaiter = new WebDriverWait(driver, context.getTestConfig().getStandardTimeout(), 600); + acWaiter = + new WebDriverWait( + driver, context.getTestConfig().getStandardTimeout(), Duration.ofMillis(600)); } public String getPromptText() { diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/searching/BulkResultsPage.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/searching/BulkResultsPage.java index 57452480f06..0c4473d3d7c 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/searching/BulkResultsPage.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/searching/BulkResultsPage.java @@ -5,6 +5,7 @@ import com.tle.webtests.pageobject.ExpectedConditions2; import com.tle.webtests.pageobject.PageObject; import com.tle.webtests.pageobject.WaitingPageObject; +import java.time.Duration; import java.util.ArrayList; import java.util.List; import org.openqa.selenium.By; @@ -29,7 +30,7 @@ public boolean waitAndFinish(WaitingPageObject targetP } public BulkResultsPage waitForAll() { - WebDriverWait waiter = new WebDriverWait(driver, 120); + WebDriverWait waiter = new WebDriverWait(driver, Duration.ofMinutes(2)); waiter.until(ExpectedConditions2.presenceOfElement(finishedMessage)); return get(); } diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/settings/MailSettingsPage.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/settings/MailSettingsPage.java index 6031f787820..52a115c69af 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/settings/MailSettingsPage.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/settings/MailSettingsPage.java @@ -2,6 +2,7 @@ import com.tle.webtests.framework.PageContext; import com.tle.webtests.pageobject.AbstractPage; +import java.time.Duration; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -96,7 +97,8 @@ public MailSettingsPage save() { public String getEmailStatus() { By xpath = By.xpath("//div[@id='emailstatus']/div[text()]"); // Wait a bit longer than normal - WebDriverWait waiter = new WebDriverWait(context.getDriver(), 60, 50); + WebDriverWait waiter = + new WebDriverWait(context.getDriver(), Duration.ofMinutes(1), Duration.ofMillis(50)); waiter.until(ExpectedConditions.visibilityOfElementLocated(xpath)); return driver.findElement(xpath).getText(); } diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/wizard/controls/AutoCompleteTermControl.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/wizard/controls/AutoCompleteTermControl.java index 90769b628a3..0ee01609b33 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/wizard/controls/AutoCompleteTermControl.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/wizard/controls/AutoCompleteTermControl.java @@ -8,6 +8,7 @@ import com.tle.webtests.pageobject.generic.component.StringSelectedStuff; import com.tle.webtests.pageobject.wizard.AbstractWizardControlPage; import com.tle.webtests.pageobject.wizard.WizardPageTab; +import java.time.Duration; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.Keys; @@ -42,7 +43,9 @@ private WebElement getSelectionsTable() { public AutoCompleteTermControl( PageContext context, int ctrlnum, AbstractWizardControlPage page) { super(context, ctrlnum, page); - acWaiter = new WebDriverWait(driver, context.getTestConfig().getStandardTimeout(), 600); + acWaiter = + new WebDriverWait( + driver, context.getTestConfig().getStandardTimeout(), Duration.ofMillis(600)); } @Override diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/wizard/controls/universal/KalturaUniversalControlType.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/wizard/controls/universal/KalturaUniversalControlType.java index 154a8c6cdc9..36021db22fa 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/wizard/controls/universal/KalturaUniversalControlType.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/wizard/controls/universal/KalturaUniversalControlType.java @@ -4,6 +4,7 @@ import com.tle.webtests.pageobject.PageObject; import com.tle.webtests.pageobject.WaitingPageObject; import com.tle.webtests.pageobject.wizard.controls.UniversalControl; +import java.time.Duration; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebElement; @@ -46,7 +47,7 @@ public enum KalturaOption { public KalturaUniversalControlType(UniversalControl control) { super(control); - this.waiter = new WebDriverWait(driver, 60, 50); + this.waiter = new WebDriverWait(driver, Duration.ofMinutes(1), Duration.ofMillis(50)); } public KalturaUniversalControlType search(String query) { diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/wizard/controls/universal/iTunesUniversalControlType.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/wizard/controls/universal/iTunesUniversalControlType.java index 5956b5c1adb..4bf1872cde9 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/wizard/controls/universal/iTunesUniversalControlType.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/wizard/controls/universal/iTunesUniversalControlType.java @@ -3,6 +3,7 @@ import com.tle.webtests.pageobject.AbstractPage; import com.tle.webtests.pageobject.WaitingPageObject; import com.tle.webtests.pageobject.wizard.controls.UniversalControl; +import java.time.Duration; import org.openqa.selenium.By; import org.openqa.selenium.SearchContext; import org.openqa.selenium.WebElement; @@ -25,7 +26,7 @@ private WebElement getTree() { public iTunesUniversalControlType(UniversalControl control) { super(control); - waiter = new WebDriverWait(context.getDriver(), 120); + waiter = new WebDriverWait(context.getDriver(), Duration.ofMinutes(2)); } @Override diff --git a/autotest/Tests/src/test/scala/equellatests/browserpage/BrowserPage.scala b/autotest/Tests/src/test/scala/equellatests/browserpage/BrowserPage.scala index 070b1fd4884..a1045b2061e 100644 --- a/autotest/Tests/src/test/scala/equellatests/browserpage/BrowserPage.scala +++ b/autotest/Tests/src/test/scala/equellatests/browserpage/BrowserPage.scala @@ -4,6 +4,7 @@ import com.tle.webtests.framework.PageContext import org.openqa.selenium.support.ui.{ExpectedCondition, ExpectedConditions, WebDriverWait} import org.openqa.selenium.{By, WebDriver, WebElement} +import java.time.Duration import scala.util.Try object BrowserPage { @@ -22,8 +23,8 @@ trait BrowserPage { def findElement(by: By): WebElement = driver.findElement(by) def findElementById(id: String): WebElement = findElement(By.id(id)) def findElementO(by: By): Option[WebElement] = Try(driver.findElement(by)).toOption - val waiter = new WebDriverWait(driver, 10, 50L) - def waitFor[A](c: ExpectedCondition[A]): A = waiter.until(c) + val waiter = new WebDriverWait(driver, Duration.ofSeconds(10), Duration.ofMillis(50)) + def waitFor[A](c: ExpectedCondition[A]): A = waiter.until(c) def updatedBy(by: By): ExpectedCondition[_] = ExpectedConditions.and( From cfe52dce66b43250245743c38cd917eaff11b3e3 Mon Sep 17 00:00:00 2001 From: Penghai Date: Mon, 3 Feb 2025 11:56:51 +1100 Subject: [PATCH 02/11] test: attempt to fix PortalsTest and DRMTest --- .../webtests/pageobject/portal/AbstractPortalSection.java | 7 +------ .../tle/webtests/pageobject/viewitem/PackageViewer.java | 3 ++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/portal/AbstractPortalSection.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/portal/AbstractPortalSection.java index bb598cb6f43..1c6fd2333b9 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/portal/AbstractPortalSection.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/portal/AbstractPortalSection.java @@ -76,12 +76,7 @@ public boolean isCloseable() { public

> P edit(P portal) { showButtons(); - WebElement editButton = - driver.findElement( - By.xpath( - "//div[contains(@title," - + quoteXPath(getTitle()) - + ")]/following-sibling::img[contains(@class, 'box_edit')]")); + WebElement editButton = getBoxHead().findElement(By.className("box_edit")); waiter.until(ExpectedConditions.elementToBeClickable(editButton)); editButton.click(); return portal.get(); diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/viewitem/PackageViewer.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/viewitem/PackageViewer.java index 2f5db5d4833..63d631290e2 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/viewitem/PackageViewer.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/viewitem/PackageViewer.java @@ -36,7 +36,8 @@ public boolean hasAttachmentNode(String attachmentName) { public boolean selectedAttachmentContainsText(String text) { switchToFrame(0); - boolean containsText = driver.findElement(By.tagName("body")).getText().contains(text); + WebElement body = waiter.until(ExpectedConditions.presenceOfElementLocated(By.tagName("body"))); + boolean containsText = body.getText().contains(text); driver.switchTo().defaultContent(); return containsText; } From 097f6fbf9744b8dd9e4ed7c91c7dbd4eca64a8cb Mon Sep 17 00:00:00 2001 From: Penghai Date: Mon, 3 Feb 2025 16:01:45 +1100 Subject: [PATCH 03/11] test: remove the redundant clicks of home page --- .../test/java/com/tle/webtests/test/dashboard/PortalsTest.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/autotest/OldTests/src/test/java/com/tle/webtests/test/dashboard/PortalsTest.java b/autotest/OldTests/src/test/java/com/tle/webtests/test/dashboard/PortalsTest.java index 13f33621b8d..f2c9c553f1e 100644 --- a/autotest/OldTests/src/test/java/com/tle/webtests/test/dashboard/PortalsTest.java +++ b/autotest/OldTests/src/test/java/com/tle/webtests/test/dashboard/PortalsTest.java @@ -351,12 +351,10 @@ public void testRecentPortal() { // Check that the queried item is displayed assertTrue(checkContributionExistence(waiter, recentName, itemToQuery)); - new MenuSection(context).home(); recent = new RecentContributionsSection(context, recentName).get(); assertTrue(recent.descriptionExists(description, true)); // Edit portlet for description option - home = new MenuSection(context).home(); recent = new RecentContributionsSection(context, recentName).get(); edit = recent.edit(portal); edit.setDisplayTitleOnly(true); @@ -364,7 +362,6 @@ public void testRecentPortal() { edit.save(new HomePage(context)); // Check that the description not displayed - new MenuSection(context).home(); recent = new RecentContributionsSection(context, recentName).get(); assertFalse(recent.descriptionExists(description, false)); } From 9754d132afa75644b089a5f617076ebf15095021 Mon Sep 17 00:00:00 2001 From: Penghai Date: Mon, 3 Feb 2025 16:31:53 +1100 Subject: [PATCH 04/11] test: wait until the text is present in the Package Viewer --- .../com/tle/webtests/pageobject/viewitem/PackageViewer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/viewitem/PackageViewer.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/viewitem/PackageViewer.java index 63d631290e2..0a290cda972 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/viewitem/PackageViewer.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/viewitem/PackageViewer.java @@ -36,8 +36,8 @@ public boolean hasAttachmentNode(String attachmentName) { public boolean selectedAttachmentContainsText(String text) { switchToFrame(0); - WebElement body = waiter.until(ExpectedConditions.presenceOfElementLocated(By.tagName("body"))); - boolean containsText = body.getText().contains(text); + boolean containsText = + waiter.until(ExpectedConditions.textToBePresentInElementLocated(By.tagName("body"), text)); driver.switchTo().defaultContent(); return containsText; } From ff9a6fe0280debb2e760548ae41db2fce3625160 Mon Sep 17 00:00:00 2001 From: Penghai Date: Tue, 4 Feb 2025 10:59:04 +1100 Subject: [PATCH 05/11] test: catch the timeout exception when the expected text is not present --- .../pageobject/viewitem/PackageViewer.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/viewitem/PackageViewer.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/viewitem/PackageViewer.java index 0a290cda972..2a2bb8185f4 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/viewitem/PackageViewer.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/viewitem/PackageViewer.java @@ -8,6 +8,7 @@ import java.util.List; import org.openqa.selenium.By; import org.openqa.selenium.StaleElementReferenceException; +import org.openqa.selenium.TimeoutException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.ExpectedCondition; @@ -35,11 +36,15 @@ public boolean hasAttachmentNode(String attachmentName) { } public boolean selectedAttachmentContainsText(String text) { - switchToFrame(0); - boolean containsText = - waiter.until(ExpectedConditions.textToBePresentInElementLocated(By.tagName("body"), text)); - driver.switchTo().defaultContent(); - return containsText; + try { + switchToFrame(0); + return waiter.until( + ExpectedConditions.textToBePresentInElementLocated(By.tagName("body"), text)); + } catch (TimeoutException e) { + return false; + } finally { + driver.switchTo().defaultContent(); + } } private void switchToFrame(int frame) { From c6f4ec69234fdec36aa8ecdb02dc55f524e2cf2a Mon Sep 17 00:00:00 2001 From: Penghai Date: Wed, 5 Feb 2025 09:49:42 +1100 Subject: [PATCH 06/11] test: remove more redundant clicks of home page --- .../java/com/tle/webtests/test/dashboard/PortalsTest.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/autotest/OldTests/src/test/java/com/tle/webtests/test/dashboard/PortalsTest.java b/autotest/OldTests/src/test/java/com/tle/webtests/test/dashboard/PortalsTest.java index f2c9c553f1e..b354d448078 100644 --- a/autotest/OldTests/src/test/java/com/tle/webtests/test/dashboard/PortalsTest.java +++ b/autotest/OldTests/src/test/java/com/tle/webtests/test/dashboard/PortalsTest.java @@ -320,7 +320,6 @@ public void testRecentPortal() { assertTrue(checkContributionExistence(waiter, recentName, liveItemName)); // Edit the portal - new MenuSection(context).home(); RecentContributionsSection recent = new RecentContributionsSection(context, recentName).get(); RecentContributionsEditPage edit = recent.edit(portal); edit.setStatus("draft"); @@ -328,7 +327,6 @@ public void testRecentPortal() { edit.save(new HomePage(context)); // Check that the draft item is displayed - home = new MenuSection(context).home(); recent = new RecentContributionsSection(context, recentName).get(); assertTrue(recent.recentContributionExists(draftItemName)); @@ -342,7 +340,8 @@ public void testRecentPortal() { wizard3.save().publish(); // Edit portlet for query option - home = new MenuSection(context).home(); + new MenuSection(context).home(); + recent = new RecentContributionsSection(context, recentName).get(); edit = recent.edit(portal); edit.setQuery("query item"); edit.setStatus("live"); From 4abd72c4f46b02015dde6bc58006208498d074b0 Mon Sep 17 00:00:00 2001 From: Penghai Date: Wed, 5 Feb 2025 14:07:13 +1100 Subject: [PATCH 07/11] test: use another method to check if the draft item exists in the Recent Portal --- .../test/java/com/tle/webtests/test/dashboard/PortalsTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/autotest/OldTests/src/test/java/com/tle/webtests/test/dashboard/PortalsTest.java b/autotest/OldTests/src/test/java/com/tle/webtests/test/dashboard/PortalsTest.java index b354d448078..37e34f2e9ef 100644 --- a/autotest/OldTests/src/test/java/com/tle/webtests/test/dashboard/PortalsTest.java +++ b/autotest/OldTests/src/test/java/com/tle/webtests/test/dashboard/PortalsTest.java @@ -327,8 +327,7 @@ public void testRecentPortal() { edit.save(new HomePage(context)); // Check that the draft item is displayed - recent = new RecentContributionsSection(context, recentName).get(); - assertTrue(recent.recentContributionExists(draftItemName)); + assertTrue(checkContributionExistence(waiter, recentName, draftItemName)); String itemToQuery = context.getFullName("query item"); String description = context.getFullName("query item description"); From a59c5f0e30c31c36aae9d61ae036a1cf6b664413 Mon Sep 17 00:00:00 2001 From: Penghai Date: Wed, 5 Feb 2025 16:27:11 +1100 Subject: [PATCH 08/11] test: update the var referencing to the home page after removing MyResource portal --- .../test/java/com/tle/webtests/test/dashboard/PortalsTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autotest/OldTests/src/test/java/com/tle/webtests/test/dashboard/PortalsTest.java b/autotest/OldTests/src/test/java/com/tle/webtests/test/dashboard/PortalsTest.java index 37e34f2e9ef..757e49c6dec 100644 --- a/autotest/OldTests/src/test/java/com/tle/webtests/test/dashboard/PortalsTest.java +++ b/autotest/OldTests/src/test/java/com/tle/webtests/test/dashboard/PortalsTest.java @@ -245,7 +245,7 @@ public void testMyResourcesPortal() { MyResourcesPortalSection myResources = new MyResourcesPortalSection(context, myResourceName).get(); - myResources.delete(); + home = myResources.delete(); assertFalse(home.portalExists(myResourceName)); } From 3acc18c95bd21f2d0a7db2d2d4bccd01ab2b5947 Mon Sep 17 00:00:00 2001 From: Penghai Date: Thu, 6 Feb 2025 10:12:52 +1100 Subject: [PATCH 09/11] test: use the standard ExpectedConditions of stalenessOf --- .../tle/webtests/pageobject/portal/AbstractPortalSection.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/portal/AbstractPortalSection.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/portal/AbstractPortalSection.java index 1c6fd2333b9..bf292fd4620 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/portal/AbstractPortalSection.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/portal/AbstractPortalSection.java @@ -7,7 +7,6 @@ import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedCondition; import org.openqa.selenium.support.ui.ExpectedConditions; public abstract class AbstractPortalSection> @@ -45,11 +44,10 @@ protected WebElement findLoadedElement() { } public HomePage delete() { - ExpectedCondition removalCondition = removalCondition(getBoxHead()); showButtons(); getBoxHead().findElement(By.className("box_close")).click(); acceptConfirmation(); - waiter.until(removalCondition); + waiter.until(ExpectedConditions.stalenessOf(getBoxHead())); return new HomePage(context).get(); } From 4aab0e6fb7c7732dbc01959cd8faf86fc2b2f64e Mon Sep 17 00:00:00 2001 From: Penghai Date: Thu, 6 Feb 2025 11:44:41 +1100 Subject: [PATCH 10/11] test: create a variable to reference to the portal box head before it's closed --- .../webtests/pageobject/portal/AbstractPortalSection.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/portal/AbstractPortalSection.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/portal/AbstractPortalSection.java index bf292fd4620..bfa8a7e84d5 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/portal/AbstractPortalSection.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/portal/AbstractPortalSection.java @@ -44,10 +44,11 @@ protected WebElement findLoadedElement() { } public HomePage delete() { + WebElement boxHead = getBoxHead(); showButtons(); - getBoxHead().findElement(By.className("box_close")).click(); + boxHead.findElement(By.className("box_close")).click(); acceptConfirmation(); - waiter.until(ExpectedConditions.stalenessOf(getBoxHead())); + waiter.until(ExpectedConditions.stalenessOf(boxHead)); return new HomePage(context).get(); } From 99a6ef310b497d9458b6e3480869c0644753bf10 Mon Sep 17 00:00:00 2001 From: Penghai Date: Tue, 11 Feb 2025 16:11:02 +1100 Subject: [PATCH 11/11] test: find the Portal box head after the calling of 'showButtons' --- .../test/java/com/tle/webtests/test/dashboard/PortalsTest.java | 2 +- .../tle/webtests/pageobject/portal/AbstractPortalSection.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/autotest/OldTests/src/test/java/com/tle/webtests/test/dashboard/PortalsTest.java b/autotest/OldTests/src/test/java/com/tle/webtests/test/dashboard/PortalsTest.java index 757e49c6dec..51350828931 100644 --- a/autotest/OldTests/src/test/java/com/tle/webtests/test/dashboard/PortalsTest.java +++ b/autotest/OldTests/src/test/java/com/tle/webtests/test/dashboard/PortalsTest.java @@ -324,7 +324,7 @@ public void testRecentPortal() { RecentContributionsEditPage edit = recent.edit(portal); edit.setStatus("draft"); edit.checkSelectedCollection(); - edit.save(new HomePage(context)); + waiter = edit.save(new HomePage(context)).getWaiter(); // Check that the draft item is displayed assertTrue(checkContributionExistence(waiter, recentName, draftItemName)); diff --git a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/portal/AbstractPortalSection.java b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/portal/AbstractPortalSection.java index bfa8a7e84d5..4d901795734 100644 --- a/autotest/Tests/src/main/java/com/tle/webtests/pageobject/portal/AbstractPortalSection.java +++ b/autotest/Tests/src/main/java/com/tle/webtests/pageobject/portal/AbstractPortalSection.java @@ -44,8 +44,8 @@ protected WebElement findLoadedElement() { } public HomePage delete() { - WebElement boxHead = getBoxHead(); showButtons(); + WebElement boxHead = getBoxHead(); boxHead.findElement(By.className("box_close")).click(); acceptConfirmation(); waiter.until(ExpectedConditions.stalenessOf(boxHead));