Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Java dependencies: Selenium, GitLab API, Netty, parent POM #1499

Merged
merged 11 commits into from Mar 9, 2024
Merged
16 changes: 11 additions & 5 deletions pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jenkins-ci</groupId>
<artifactId>jenkins</artifactId>
<version>1.108</version>
<version>1.111</version>
</parent>

<artifactId>acceptance-test-harness</artifactId>
Expand All @@ -31,7 +31,7 @@
<changelist>999999-SNAPSHOT</changelist>
<spotbugs.skip>true</spotbugs.skip>
<jenkins.version>2.443</jenkins.version>
<selenium.version>4.14.0</selenium.version>
<selenium.version>4.18.1</selenium.version>
<guava.version>33.0.0-jre</guava.version> <!-- aligned with selenium -->
<maven.version>3.8.1</maven.version>
<maven-resolver.version>1.6.2</maven-resolver.version>
Expand All @@ -58,7 +58,7 @@
<dependency>
<groupId>org.gitlab4j</groupId>
<artifactId>gitlab4j-api</artifactId>
<version>5.2.0</version>
<version>5.5.0</version>
</dependency>
<dependency>
<groupId>args4j</groupId>
Expand Down Expand Up @@ -350,7 +350,7 @@
<!-- upper bounds conflict -->
<groupId>io.netty</groupId>
<artifactId>netty-bom</artifactId>
<version>4.1.104.Final</version>
<version>4.1.107.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -363,7 +363,13 @@
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.14.11</version>
<version>1.14.12</version>
</dependency>
<!-- RequireUpperBoundDeps between jersey (via GitLab API) and browserup -->
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.29.0-GA</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/jenkinsci/test/acceptance/FallbackConfig.java
Expand Up @@ -69,7 +69,7 @@
import org.openqa.selenium.remote.LocalFileDetector;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.safari.SafariDriver;
import org.openqa.selenium.support.events.EventFiringWebDriver;
import org.openqa.selenium.support.events.EventFiringDecorator;
import org.openqa.selenium.support.ui.ExpectedConditions;

/**
Expand Down Expand Up @@ -112,9 +112,9 @@ private WebDriver createWebDriver(TestCleaner cleaner, TestName testName) throws
GeckoDriverService service = builder.build();
return new FirefoxDriver(service, buildFirefoxOptions(testName));
case "firefox-container":
return createContainerWebDriver(cleaner, "selenium/standalone-firefox:4.14.1", buildFirefoxOptions(testName));
return createContainerWebDriver(cleaner, "selenium/standalone-firefox:4.18.1", buildFirefoxOptions(testName));
case "chrome-container":
return createContainerWebDriver(cleaner, "selenium/standalone-chrome:4.14.1", new ChromeOptions());
return createContainerWebDriver(cleaner, "selenium/standalone-chrome:4.18.1", new ChromeOptions());
case "chrome":
Map<String, String> prefs = new HashMap<String, String>();
prefs.put(LANGUAGE_SELECTOR, "en");
Expand Down Expand Up @@ -320,9 +320,9 @@ public WebDriver createWebDriver(TestCleaner cleaner, TestName testName, Elastic
if (oldSize.height < 1050 || oldSize.width < 1680) {
base.manage().window().setSize(new Dimension(1680, 1050));
}

final EventFiringWebDriver d = new EventFiringWebDriver(base);
d.register(new Scroller());
Scroller scroller = new Scroller(base);
final EventFiringDecorator<WebDriver> decorator = new EventFiringDecorator<>(scroller);
WebDriver d = decorator.decorate(base);

try {
d.manage().timeouts().pageLoadTimeout(Duration.ofMillis(time.seconds(PAGE_LOAD_TIMEOUT)));
Expand Down
Expand Up @@ -58,7 +58,7 @@ protected WebElement find(String caption) {
String id = getElement(by.name("config.id")).getAttribute("value");
// clicking the button leads to the load of a new page but it is not a navigation event from the listeners PoV
// so we need to disable the sticky elmements again
new Scroller().disableStickyElements(driver);
new Scroller(driver).disableStickyElements();
return newInstance(type, this, id);
}
}
Expand Up @@ -59,7 +59,7 @@ private void findAndPerformClick(final By addSubmitButtonLocator) {

final Actions builder = new Actions(driver);

new Scroller().scrollIntoView(addSubmitButton, driver);
new Scroller(driver).scrollIntoView(addSubmitButton);
addSubmitButton.click();
builder.perform();
}
Expand Down
Expand Up @@ -105,7 +105,7 @@ public <T> T configure(final Callable<T> body) {
public void configure() {
// Automatic disabling of sticky elements doesn't seem to occur after a redirect,
// so force it after the configuration page has loaded
new Scroller().disableStickyElements(driver);
new Scroller(driver).disableStickyElements();

if (!driver.getCurrentUrl().equals(getConfigUrl().toExternalForm())) {
visit(getConfigUrl());
Expand Down
Expand Up @@ -45,7 +45,7 @@ public <T extends TopLevelItem> T create(Class<T> type, String name) {

// Automatic disabling of sticky elements doesn't seem to occur after a redirect,
// so force it after the configuration page has loaded
new Scroller().disableStickyElements(driver);
new Scroller(driver).disableStickyElements();

final T j = get(type, name);

Expand Down
Expand Up @@ -43,7 +43,7 @@ public <S extends Slave> S create(Class<S> type, String name) {
S s = newInstance(type, jenkins, name);
// Automatic disabling of sticky elements doesn't occur after a redirect
// so force it after the configuration page has loaded
new Scroller().disableStickyElements(driver);
new Scroller(driver).disableStickyElements();


// reasonable starting point values
Expand Down
30 changes: 18 additions & 12 deletions src/main/java/org/jenkinsci/test/acceptance/selenium/Scroller.java
Expand Up @@ -15,7 +15,7 @@
import org.openqa.selenium.UnhandledAlertException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.events.AbstractWebDriverEventListener;
import org.openqa.selenium.support.events.WebDriverListener;

/**
* Automatically scrolls the element into view.
Expand Down Expand Up @@ -71,14 +71,16 @@
* @author ogondza
* @author Kohsuke Kawaguchi
*/
public class Scroller extends AbstractWebDriverEventListener {
public class Scroller implements WebDriverListener {

private final Logger LOGGER = Logger.getLogger(Scroller.class.getName());

private final String scrollJs;
private final String disableStickyElementsJs;
private final WebDriver driver;

public Scroller() {
public Scroller(WebDriver driver) {
this.driver = driver;
try {
scrollJs = IOUtils.toString(getClass()
.getResourceAsStream("scroller.js"), StandardCharsets.UTF_8);
Expand All @@ -90,25 +92,29 @@ public Scroller() {
}

@Override
public void beforeClickOn(WebElement element, WebDriver driver) {
scrollIntoView(element, driver);
public void beforeClick(WebElement element) {
scrollIntoView(element);
}

@Override
public void beforeChangeValueOf(WebElement element, WebDriver driver, CharSequence[] keysToSend) {
scrollIntoView(element, driver);
public void beforeSendKeys(WebElement element, CharSequence[] keysToSend) {
scrollIntoView(element);
}

@Override
public void afterNavigateTo(String url, WebDriver driver) {
super.afterNavigateTo(url, driver);
public void beforeClear(WebElement element) {
scrollIntoView(element);
}

@Override
public void afterGet(WebDriver driver, String url) {
try {
// if there's an alert we can't run JavaScript
// if we catch the exception from running JavaScript then FormValidationTest hangs
// not the nicest hack, but it works
driver.switchTo().alert();
} catch (NoAlertPresentException e) {
disableStickyElements(driver);
disableStickyElements();
}
}

Expand All @@ -117,7 +123,7 @@ public void afterNavigateTo(String url, WebDriver driver) {
* appear on top of other elements, making those elements inaccessible. This method removes the sticky
* nature of these elements meaning that they'll no longer appear on top of other elements.
*/
public void disableStickyElements(WebDriver driver) {
public void disableStickyElements() {
final JavascriptExecutor executor = (JavascriptExecutor) driver;
try {
executor.executeScript(disableStickyElementsJs);
Expand All @@ -130,7 +136,7 @@ public void disableStickyElements(WebDriver driver) {
* The framework is expected to take care of the correct scrolling. When you are tempted to scroll from PageObjects
* or tests, there is likely a framework problem to be fixed.
*/
public void scrollIntoView(WebElement e, WebDriver driver) {
public void scrollIntoView(WebElement e) {
WebElement element = e;
if (Objects.equals(element.getTagName(), "option")) {
element = e.findElement(By.xpath("..")); // scroll select into view not option
Expand Down
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
20 changes: 10 additions & 10 deletions src/test/resources/artifactory_plugin/quickstart/gradlew.bat
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down