Skip to content

Commit e1fbce3

Browse files
authored
Remove WebDriverManager dependency and update to Selenium 4.13 +semver: feature (#130)
* Remove WebDriverManager dependency and update to Selenium 4.13 - As now built-in Selenium Manager allows to download driver, we don't need to maintain webDriverManager dependency. - updated core library to use Selenium 4.13 (latest supported for Java 8) - removed jackson-databind dependency - update testng to 7.5.1 (latest supported for Java 8) - added commons-lang dependency - add workflow to automatically deploy to maven central after PR merge * Update tests * Update the-internet URL in tests to use https
1 parent 122e911 commit e1fbce3

28 files changed

+136
-169
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Publish package to Maven Central
2+
on:
3+
pull_request:
4+
branches:
5+
- master
6+
types: [closed]
7+
8+
jobs:
9+
publish:
10+
if: github.event.pull_request.merged == true
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Step 1 - Checkout code
14+
uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Step 2 - Set up Maven Central Repository
19+
uses: actions/setup-java@v3
20+
with:
21+
java-version: "8"
22+
distribution: "adopt"
23+
server-id: ossrh
24+
server-username: MVN_CENTRAL_USERNAME
25+
server-password: MVN_CENTRAL_PASSWORD
26+
gpg-private-key: ${{ secrets.GPG_SECRET_KEY }}
27+
gpg-passphrase: MVN_GPG_PASSPHRASE
28+
29+
- name: Step 3 - Install GitVersion
30+
uses: gittools/actions/gitversion/setup@v0
31+
with:
32+
versionSpec: '5.x'
33+
34+
- name: Step 4 - Determine Version
35+
id: gitversion
36+
uses: gittools/actions/gitversion/execute@v0
37+
with:
38+
useConfigFile: true
39+
40+
- name: Step 5 - Create Release
41+
id: create_release
42+
uses: actions/create-release@latest
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
TITLE: ${{ github.event.pull_request.title }}
46+
BODY: ${{ github.event.pull_request.body }}
47+
VERSION: "v${{ steps.gitversion.outputs.semVer }}"
48+
with:
49+
tag_name: ${{ env.VERSION }}
50+
release_name: ${{ env.VERSION }} ${{ env.TITLE }}
51+
body: ${{ env.BODY }}
52+
draft: false
53+
prerelease: false
54+
55+
- name: Step 6 - Publish package
56+
run: |
57+
mvn -Dmaven.test.skip=true -P release -Drevision=${{ steps.gitversion.outputs.semVer }} deploy
58+
env:
59+
MVN_CENTRAL_USERNAME: ${{ secrets.OSSRH_USERNAME }}
60+
MVN_CENTRAL_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
61+
MVN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2023 Aquality Automation
189+
Copyright 2024 Aquality Automation
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

pom.xml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.github.aquality-automation</groupId>
88
<artifactId>aquality-selenium</artifactId>
9-
<version>4.0.1</version>
9+
<version>${revision}</version>
1010
<packaging>jar</packaging>
1111
<name>Aquality Selenium</name>
1212
<description>Library around Selenium WebDriver</description>
@@ -15,6 +15,7 @@
1515
<properties>
1616
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
1717
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
<revision>4.0.0-SNAPSHOT</revision>
1819
</properties>
1920

2021
<distributionManagement>
@@ -81,25 +82,22 @@
8182
<dependency>
8283
<groupId>com.github.aquality-automation</groupId>
8384
<artifactId>aquality-selenium-core</artifactId>
84-
<version>3.0.0</version>
85+
<version>3.1.0</version>
8586
</dependency>
86-
8787
<dependency>
88-
<groupId>io.github.bonigarcia</groupId>
89-
<artifactId>webdrivermanager</artifactId>
90-
<version>5.3.2</version>
88+
<groupId>org.apache.commons</groupId>
89+
<artifactId>commons-lang3</artifactId>
90+
<version>3.13.0</version>
9191
</dependency>
92-
9392
<dependency>
94-
<groupId>com.fasterxml.jackson.core</groupId>
95-
<artifactId>jackson-databind</artifactId>
96-
<version>2.14.2</version>
93+
<groupId>org.slf4j</groupId>
94+
<artifactId>slf4j-simple</artifactId>
95+
<version>2.0.10</version>
9796
</dependency>
98-
9997
<dependency>
10098
<groupId>org.testng</groupId>
10199
<artifactId>testng</artifactId>
102-
<version>7.5</version>
100+
<version>7.5.1</version>
103101
<scope>test</scope>
104102
</dependency>
105103
</dependencies>
@@ -187,6 +185,9 @@
187185
<plugin>
188186
<groupId>org.apache.maven.plugins</groupId>
189187
<artifactId>maven-javadoc-plugin</artifactId>
188+
<configuration>
189+
<source>8</source>
190+
</configuration>
190191
<executions>
191192
<execution>
192193
<id>attach-javadocs</id>
@@ -207,6 +208,12 @@
207208
<goals>
208209
<goal>sign</goal>
209210
</goals>
211+
<configuration>
212+
<gpgArguments>
213+
<arg>--pinentry-mode</arg>
214+
<arg>loopback</arg>
215+
</gpgArguments>
216+
</configuration>
210217
</execution>
211218
</executions>
212219
</plugin>

src/main/java/aquality/selenium/browser/Browser.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
import aquality.selenium.core.localization.ILocalizationManager;
1010
import aquality.selenium.core.localization.ILocalizedLogger;
1111
import aquality.selenium.core.waitings.IConditionalWait;
12-
import org.apache.commons.io.IOUtils;
13-
import org.apache.commons.lang3.NotImplementedException;
1412
import org.openqa.selenium.*;
1513
import org.openqa.selenium.WebDriver.Navigation;
1614
import org.openqa.selenium.devtools.HasDevTools;
@@ -21,7 +19,6 @@
2119

2220
import java.io.File;
2321
import java.io.IOException;
24-
import java.nio.charset.StandardCharsets;
2522
import java.time.Duration;
2623
import java.util.function.Supplier;
2724

@@ -147,7 +144,8 @@ public IBrowserTabNavigation tabs() {
147144
}
148145

149146
/**
150-
* Sets page load timeout (Will be ignored for Safari https://github.com/SeleniumHQ/selenium-google-code-issue-archive/issues/687)
147+
* Sets page load timeout (Will be ignored for Safari
148+
* <a href="https://github.com/SeleniumHQ/selenium-google-code-issue-archive/issues/687">...</a>)
151149
*
152150
* @param timeout seconds to wait
153151
*/
@@ -248,10 +246,9 @@ public Object executeAsyncScript(JavaScript scriptName, Object... args) {
248246
* @param file Java Script file
249247
* @param arguments Arguments for the script (web elements, values etc.
250248
* @return Result object of script execution
251-
* @throws IOException in case of problems with the File
252249
*/
253-
public Object executeAsyncScript(final File file, Object... arguments) throws IOException {
254-
return executeAsyncScript(IOUtils.toString(file.toURI(), StandardCharsets.UTF_8.name()), arguments);
250+
public Object executeAsyncScript(final File file, Object... arguments) {
251+
return executeAsyncScript(JavaScript.readScript(file), arguments);
255252
}
256253

257254
/**
@@ -303,7 +300,7 @@ public Object executeScript(JavaScript scriptName, Object... args) {
303300
* @throws IOException in case of problems with the File
304301
*/
305302
public Object executeScript(final File file, Object... arguments) throws IOException {
306-
return executeScript(IOUtils.toString(file.toURI(), StandardCharsets.UTF_8.name()), arguments);
303+
return executeScript(JavaScript.readScript(file), arguments);
307304
}
308305

309306
/**
@@ -400,7 +397,7 @@ public DevToolsHandling devTools() {
400397
return devTools;
401398
}
402399
else {
403-
throw new NotImplementedException("DevTools protocol is not supported for current browser.");
400+
throw new UnsupportedOperationException("DevTools protocol is not supported for current browser.");
404401
}
405402
}
406403

src/main/java/aquality/selenium/browser/JavaScript.java

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package aquality.selenium.browser;
22

33
import aquality.selenium.core.logging.Logger;
4-
import org.apache.commons.io.IOUtils;
4+
import org.apache.logging.log4j.core.util.IOUtils;
55

6-
import java.io.IOException;
7-
import java.io.InputStream;
6+
import java.io.*;
87
import java.net.URL;
98
import java.nio.charset.StandardCharsets;
9+
import java.nio.file.Files;
1010

1111
import static java.lang.String.format;
1212

@@ -59,11 +59,28 @@ public String getScript() {
5959
URL scriptFile = getClass().getResource("/js/" + filename);
6060
if (scriptFile != null) {
6161
try (InputStream stream = scriptFile.openStream()) {
62-
return IOUtils.toString(stream, StandardCharsets.UTF_8.name());
62+
return readScript(stream);
6363
} catch (IOException e) {
64-
Logger.getInstance().fatal(format("Couldn't find the script \"%s\"", filename), e);
64+
logScriptAbsence(filename, e);
6565
}
6666
}
6767
return "";
6868
}
69+
70+
static String readScript(final File file) {
71+
try (InputStream stream = Files.newInputStream(file.toPath())) {
72+
return readScript(stream);
73+
} catch (IOException e) {
74+
logScriptAbsence(file.getName(), e);
75+
return "";
76+
}
77+
}
78+
79+
private static void logScriptAbsence(String filename, IOException e) {
80+
Logger.getInstance().fatal(format("Couldn't find the script \"%s\"", filename), e);
81+
}
82+
83+
private static String readScript(InputStream stream) throws IOException {
84+
return IOUtils.toString(new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8)));
85+
}
6986
}

src/main/java/aquality/selenium/browser/LocalBrowserFactory.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
import aquality.selenium.configuration.driversettings.IDriverSettings;
55
import aquality.selenium.core.localization.ILocalizedLogger;
66
import aquality.selenium.core.utilities.IActionRetrier;
7-
import io.github.bonigarcia.wdm.WebDriverManager;
8-
import io.github.bonigarcia.wdm.config.Architecture;
9-
import org.openqa.selenium.Capabilities;
107
import org.openqa.selenium.chrome.ChromeDriver;
118
import org.openqa.selenium.chrome.ChromeOptions;
129
import org.openqa.selenium.edge.EdgeDriver;
@@ -15,7 +12,6 @@
1512
import org.openqa.selenium.firefox.FirefoxOptions;
1613
import org.openqa.selenium.ie.InternetExplorerDriver;
1714
import org.openqa.selenium.ie.InternetExplorerOptions;
18-
import org.openqa.selenium.remote.AbstractDriverOptions;
1915
import org.openqa.selenium.remote.RemoteWebDriver;
2016
import org.openqa.selenium.safari.SafariDriver;
2117
import org.openqa.selenium.safari.SafariOptions;
@@ -34,8 +30,6 @@ protected RemoteWebDriver getDriver() {
3430
BrowserName browserName = browserProfile.getBrowserName();
3531
RemoteWebDriver driver;
3632
IDriverSettings driverSettings = browserProfile.getDriverSettings();
37-
String webDriverVersion = driverSettings.getWebDriverVersion();
38-
Architecture systemArchitecture = driverSettings.getSystemArchitecture();
3933
switch (browserName) {
4034
case CHROME:
4135
case YANDEX:
@@ -45,18 +39,16 @@ protected RemoteWebDriver getDriver() {
4539
driver = new FirefoxDriver((FirefoxOptions) driverSettings.getDriverOptions());
4640
break;
4741
case IEXPLORER:
48-
WebDriverManager.iedriver().architecture(systemArchitecture).driverVersion(webDriverVersion).setup();
4942
driver = new InternetExplorerDriver((InternetExplorerOptions) driverSettings.getDriverOptions());
5043
break;
5144
case EDGE:
52-
WebDriverManager.edgedriver().driverVersion(webDriverVersion).setup();
5345
driver = new EdgeDriver((EdgeOptions) driverSettings.getDriverOptions());
5446
break;
5547
case SAFARI:
5648
driver = new SafariDriver((SafariOptions) driverSettings.getDriverOptions());
5749
break;
5850
default:
59-
throw new IllegalArgumentException(String.format("Browser [%s] is not supported.", browserName));
51+
throw new UnsupportedOperationException(String.format("Browser [%s] is not supported.", browserName));
6052
}
6153
return driver;
6254
}

src/main/java/aquality/selenium/browser/devtools/DevToolsHandling.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import aquality.selenium.browser.AqualityServices;
44
import aquality.selenium.core.localization.ILocalizedLogger;
5-
import org.apache.commons.lang3.NotImplementedException;
65
import org.openqa.selenium.chromium.ChromiumDriver;
76
import org.openqa.selenium.devtools.Command;
87
import org.openqa.selenium.devtools.DevTools;
@@ -132,7 +131,7 @@ public Map<String, Object> executeCdpCommand(String commandName, Map<String, Obj
132131
return result;
133132
}
134133
else {
135-
throw new NotImplementedException("Execution of CDP command directly is not supported for current browser. Try sendCommand method instead.");
134+
throw new UnsupportedOperationException("Execution of CDP command directly is not supported for current browser. Try sendCommand method instead.");
136135
}
137136
}
138137

src/main/java/aquality/selenium/browser/devtools/JavaScriptHandling.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import aquality.selenium.browser.AqualityServices;
44
import aquality.selenium.core.localization.ILocalizedLogger;
5-
import org.apache.commons.lang3.NotImplementedException;
65
import org.openqa.selenium.JavascriptException;
76
import org.openqa.selenium.JavascriptExecutor;
87
import org.openqa.selenium.ScriptKey;
@@ -174,7 +173,7 @@ public void unpinScript(ScriptKey pinnedScript) {
174173

175174
/**
176175
* Gets list of previously pinned scripts.
177-
* @return a list of previously pinned scripts.
176+
* @return a set of previously pinned scripts.
178177
*/
179178
public Set<ScriptKey> getPinnedScripts() {
180179
logger.info("loc.browser.javascript.snippets.get");
@@ -227,7 +226,7 @@ public <X> void onLogEvent(EventType<X> kind) {
227226
}
228227
}).augment(driver);
229228
if (!(driver instanceof HasLogEvents)) {
230-
throw new NotImplementedException(
229+
throw new UnsupportedOperationException(
231230
String.format("Driver for the current browser [%s] doesn't implement HasLogEvents", browserName));
232231
}
233232
}

src/main/java/aquality/selenium/configuration/BrowserProfile.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,14 @@ public IDriverSettings getDriverSettings() {
4949
case IEXPLORER:
5050
driverSettings = new IExplorerSettings(settingsFile);
5151
break;
52-
case OPERA:
53-
driverSettings = new OperaSettings(settingsFile);
54-
break;
5552
case SAFARI:
5653
driverSettings = new SafariSettings(settingsFile);
5754
break;
5855
case YANDEX:
5956
driverSettings = new YandexSettings(settingsFile);
6057
break;
6158
default:
62-
throw new IllegalArgumentException("There are no assigned behaviour for retrieving driver driversettings for browser " + getBrowserName());
59+
throw new UnsupportedOperationException("There are no assigned behaviour for retrieving driver driversettings for browser " + getBrowserName());
6360
}
6461
return driverSettings;
6562
}

src/main/java/aquality/selenium/configuration/driversettings/DriverSettings.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import aquality.selenium.core.localization.ILocalizationManager;
55
import aquality.selenium.core.logging.Logger;
66
import aquality.selenium.core.utilities.ISettingsFile;
7-
import io.github.bonigarcia.wdm.config.Architecture;
87
import org.apache.commons.lang3.StringUtils;
98
import org.openqa.selenium.MutableCapabilities;
109
import org.openqa.selenium.PageLoadStrategy;
@@ -101,22 +100,6 @@ private final <T> void logCollection(String messageKey, final T... elements) {
101100
}
102101
}
103102

104-
@Override
105-
public String getWebDriverVersion() {
106-
return String.valueOf(getSettingsFile().getValueOrDefault(
107-
getDriverSettingsPath("webDriverVersion"), "Latest"));
108-
}
109-
110-
@Override
111-
public Architecture getSystemArchitecture() {
112-
String strValue = String.valueOf(getSettingsFile().getValueOrDefault(
113-
getDriverSettingsPath("systemArchitecture"), "Auto"));
114-
return Arrays.stream(Architecture.values())
115-
.filter(value -> value.name().equals(strValue))
116-
.findFirst()
117-
.orElse(Architecture.X32);
118-
}
119-
120103
@Override
121104
public PageLoadStrategy getPageLoadStrategy() {
122105
String value = (String) getSettingsFile().getValueOrDefault(getDriverSettingsPath("pageLoadStrategy"), "normal");

0 commit comments

Comments
 (0)