Skip to content

Commit 71b5013

Browse files
committed
Merge branch 'master' into enhancement/use-native-open-new-tab-function
2 parents 26b504a + 9445843 commit 71b5013

34 files changed

+383
-155
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 }}

GitVersion.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
mode: Mainline
2+
increment: Inherit
3+
branches: {}
4+
ignore:
5+
sha: []
6+

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: 26 additions & 13 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.0</version>
9+
<version>${revision}</version>
1010
<packaging>jar</packaging>
1111
<name>Aquality Selenium</name>
1212
<description>Library around Selenium WebDriver</description>
@@ -15,16 +15,17 @@
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>
2122
<snapshotRepository>
2223
<id>ossrh</id>
23-
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
24+
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
2425
</snapshotRepository>
2526
<repository>
2627
<id>ossrh</id>
27-
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
28+
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
2829
</repository>
2930
</distributionManagement>
3031

@@ -81,25 +82,28 @@
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.2</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>
9493
<groupId>com.fasterxml.jackson.core</groupId>
9594
<artifactId>jackson-databind</artifactId>
96-
<version>2.14.2</version>
95+
<version>2.16.1</version>
96+
</dependency>
97+
<dependency>
98+
<groupId>org.slf4j</groupId>
99+
<artifactId>slf4j-simple</artifactId>
100+
<version>2.0.10</version>
101+
<scope>test</scope>
97102
</dependency>
98-
99103
<dependency>
100104
<groupId>org.testng</groupId>
101105
<artifactId>testng</artifactId>
102-
<version>7.5</version>
106+
<version>7.5.1</version>
103107
<scope>test</scope>
104108
</dependency>
105109
</dependencies>
@@ -187,6 +191,9 @@
187191
<plugin>
188192
<groupId>org.apache.maven.plugins</groupId>
189193
<artifactId>maven-javadoc-plugin</artifactId>
194+
<configuration>
195+
<source>8</source>
196+
</configuration>
190197
<executions>
191198
<execution>
192199
<id>attach-javadocs</id>
@@ -207,6 +214,12 @@
207214
<goals>
208215
<goal>sign</goal>
209216
</goals>
217+
<configuration>
218+
<gpgArguments>
219+
<arg>--pinentry-mode</arg>
220+
<arg>loopback</arg>
221+
</gpgArguments>
222+
</configuration>
210223
</execution>
211224
</executions>
212225
</plugin>
@@ -217,7 +230,7 @@
217230
<extensions>true</extensions>
218231
<configuration>
219232
<serverId>ossrh</serverId>
220-
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
233+
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
221234
<autoReleaseAfterClose>true</autoReleaseAfterClose>
222235
</configuration>
223236
</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: 23 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

@@ -22,6 +22,7 @@ public enum JavaScript {
2222
GET_COMBOBOX_SELECTED_TEXT("getCmbText.js"),
2323
GET_COMBOBOX_TEXTS("getCmbValues.js"),
2424
GET_ELEMENT_BY_XPATH("getElementByXpath.js"),
25+
GET_ELEMENT_CSS_SELECTOR("getElementCssSelector.js"),
2526
GET_ELEMENT_XPATH("getElementXPath.js"),
2627
GET_ELEMENT_TEXT("getElementText.js"),
2728
GET_TEXT_FIRST_CHILD("getTextFirstChild.js"),
@@ -59,11 +60,28 @@ public String getScript() {
5960
URL scriptFile = getClass().getResource("/js/" + filename);
6061
if (scriptFile != null) {
6162
try (InputStream stream = scriptFile.openStream()) {
62-
return IOUtils.toString(stream, StandardCharsets.UTF_8.name());
63+
return readScript(stream);
6364
} catch (IOException e) {
64-
Logger.getInstance().fatal(format("Couldn't find the script \"%s\"", filename), e);
65+
logScriptAbsence(filename, e);
6566
}
6667
}
6768
return "";
6869
}
70+
71+
static String readScript(final File file) {
72+
try (InputStream stream = Files.newInputStream(file.toPath())) {
73+
return readScript(stream);
74+
} catch (IOException e) {
75+
logScriptAbsence(file.getName(), e);
76+
return "";
77+
}
78+
}
79+
80+
private static void logScriptAbsence(String filename, IOException e) {
81+
Logger.getInstance().fatal(format("Couldn't find the script \"%s\"", filename), e);
82+
}
83+
84+
private static String readScript(InputStream stream) throws IOException {
85+
return IOUtils.toString(new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8)));
86+
}
6987
}

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

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,15 @@
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;
8+
import org.openqa.selenium.chrome.ChromeDriverService;
119
import org.openqa.selenium.chrome.ChromeOptions;
1210
import org.openqa.selenium.edge.EdgeDriver;
1311
import org.openqa.selenium.edge.EdgeOptions;
1412
import org.openqa.selenium.firefox.FirefoxDriver;
1513
import org.openqa.selenium.firefox.FirefoxOptions;
1614
import org.openqa.selenium.ie.InternetExplorerDriver;
1715
import org.openqa.selenium.ie.InternetExplorerOptions;
18-
import org.openqa.selenium.remote.AbstractDriverOptions;
1916
import org.openqa.selenium.remote.RemoteWebDriver;
2017
import org.openqa.selenium.safari.SafariDriver;
2118
import org.openqa.selenium.safari.SafariOptions;
@@ -34,35 +31,29 @@ protected RemoteWebDriver getDriver() {
3431
BrowserName browserName = browserProfile.getBrowserName();
3532
RemoteWebDriver driver;
3633
IDriverSettings driverSettings = browserProfile.getDriverSettings();
37-
String webDriverVersion = driverSettings.getWebDriverVersion();
38-
Architecture systemArchitecture = driverSettings.getSystemArchitecture();
3934
switch (browserName) {
4035
case CHROME:
41-
case YANDEX:
42-
WebDriverManager.chromedriver().driverVersion(webDriverVersion).setup();
4336
driver = new ChromeDriver((ChromeOptions) driverSettings.getDriverOptions());
4437
break;
38+
case YANDEX:
4539
case OPERA:
46-
WebDriverManager.operadriver().driverVersion(webDriverVersion).setup();
47-
driver = new ChromeDriver((ChromeOptions) driverSettings.getDriverOptions());
40+
driver = new ChromeDriver(new ChromeDriverService.Builder().withBuildCheckDisabled(true).build(),
41+
(ChromeOptions) driverSettings.getDriverOptions());
4842
break;
4943
case FIREFOX:
50-
WebDriverManager.firefoxdriver().driverVersion(webDriverVersion).setup();
5144
driver = new FirefoxDriver((FirefoxOptions) driverSettings.getDriverOptions());
5245
break;
5346
case IEXPLORER:
54-
WebDriverManager.iedriver().architecture(systemArchitecture).driverVersion(webDriverVersion).setup();
5547
driver = new InternetExplorerDriver((InternetExplorerOptions) driverSettings.getDriverOptions());
5648
break;
5749
case EDGE:
58-
WebDriverManager.edgedriver().driverVersion(webDriverVersion).setup();
5950
driver = new EdgeDriver((EdgeOptions) driverSettings.getDriverOptions());
6051
break;
6152
case SAFARI:
6253
driver = new SafariDriver((SafariOptions) driverSettings.getDriverOptions());
6354
break;
6455
default:
65-
throw new IllegalArgumentException(String.format("Browser [%s] is not supported.", browserName));
56+
throw new UnsupportedOperationException(String.format("Browser [%s] is not supported.", browserName));
6657
}
6758
return driver;
6859
}

0 commit comments

Comments
 (0)