Skip to content

Commit

Permalink
Merge pull request #3522 from openequella/renovate/org.seleniumhq.sel…
Browse files Browse the repository at this point in the history
…enium-selenium-java-4.x

chore(deps): update dependency org.seleniumhq.selenium:selenium-java to v4
  • Loading branch information
edalex-ian authored Nov 6, 2024
2 parents 4221008 + 792b61c commit a72cb85
Show file tree
Hide file tree
Showing 28 changed files with 74 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1067,7 +1068,7 @@ private List<WebElement> 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);
}
Expand All @@ -1086,7 +1087,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);
Expand All @@ -1099,7 +1100,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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<WebDriver, Boolean>)
driver -> {
Expand Down
2 changes: 1 addition & 1 deletion autotest/Tests/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object> waiter =
new FluentWait<Object>(Void.class)
.withTimeout(10, TimeUnit.SECONDS)
.pollingEvery(50, TimeUnit.MILLISECONDS);
.withTimeout(Duration.ofSeconds(10))
.pollingEvery(Duration.ofMillis(50));
private LazyTemplatedElementLocator locator;
private RefreshingElementProxyCreator proxyCreator;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -56,23 +57,28 @@ 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -30,7 +31,7 @@ public void setReason(String reason) {
(Function<WebDriver, Object>)
webDriver -> {
try {
new WebDriverWait(webDriver, 1)
new WebDriverWait(webDriver, Duration.ofSeconds(1))
.until(ExpectedConditions.stalenessOf(getContinueButton()));
return false;
} catch (TimeoutException toe) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -54,7 +55,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,7 +21,7 @@ public class MigrationProgressDialog extends AbstractPage<MigrationProgressDialo

public MigrationProgressDialog(PageContext context) {
super(context, By.className("progress-curr-migration"));
longWaiter = new WebDriverWait(context.getDriver(), 180);
longWaiter = new WebDriverWait(context.getDriver(), Duration.ofMinutes(3));
}

public void close() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.tle.webtests.framework.PageContext;
import com.tle.webtests.pageobject.AbstractPage;
import com.tle.webtests.pageobject.WaitingPageObject;
import java.time.Duration;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
Expand Down Expand Up @@ -33,7 +34,7 @@ public StatusPage(PageContext context, WaitingPageObject<T> tab) {
}

public StatusPage(PageContext context, WaitingPageObject<T> tab, long timeout) {
super(context, new WebDriverWait(context.getDriver(), timeout));
super(context, new WebDriverWait(context.getDriver(), Duration.ofSeconds(timeout)));
mustBeVisible = false;
this.tab = tab;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -13,7 +14,7 @@ public class UpgradeStepsPage extends AbstractPage<UpgradeStepsPage> {

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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand Down
Loading

0 comments on commit a72cb85

Please sign in to comment.