Skip to content

Commit 9656b0e

Browse files
authored
Integrate WebDriver Manager Beta (#12)
WebDriver Manager Beta and bumped dependencies - This PR introduces the WebDriver Manager Beta version to the project, allowing for better support of newer browser drivers and enhanced compatibility with evolving browser and OS updates.
1 parent 0c8f4d2 commit 9656b0e

File tree

9 files changed

+36
-162
lines changed

9 files changed

+36
-162
lines changed

.github/scripts/downloadDriver.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/run.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: run
33
on:
44
pull_request:
55
branches: [ "master" ]
6+
push:
7+
branches: [ "feature/WebDriverManager" ]
68

79
jobs:
810
build:
@@ -25,12 +27,7 @@ jobs:
2527
- name: Install Google Chrome # Using shell script to install Google Chrome
2628
run: |
2729
chmod +x ./.github/scripts/InstallChrome.sh
28-
./.github/scripts/InstallChrome.sh
29-
30-
- name: Install Chrome Driver # Using shell script to install Chrome Driver
31-
run: |
32-
chmod +x ./.github/scripts/downloadDriver.sh
33-
./.github/scripts/downloadDriver.sh "/wikipedia/src/test/resources/drivers"
30+
./.github/scripts/InstallChrome.sh
3431
3532
- run: |
3633
export DISPLAY=:99
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
weather.url.value=http://api.openweathermap.org/data/2.5/weather
22
wikipedia.url.value=https://www.wikipedia.org/
3-
browser=google
3+
browser=chrome

pom.xml

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<parent>
3535
<groupId>org.springframework.boot</groupId>
3636
<artifactId>spring-boot-starter-parent</artifactId>
37-
<version>3.2.3</version>
37+
<version>3.5.0</version>
3838
<relativePath/>
3939
</parent>
4040

@@ -43,7 +43,7 @@
4343
<dependency>
4444
<groupId>org.springframework.boot</groupId>
4545
<artifactId>spring-boot-dependencies</artifactId>
46-
<version>3.2.3</version>
46+
<version>3.5.0</version>
4747
<type>pom</type>
4848
<scope>import</scope>
4949
</dependency>
@@ -55,21 +55,18 @@
5555
<java.version>17</java.version>
5656
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5757
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
58-
<json.version>20240205</json.version>
59-
<rest-assured.version>5.4.0</rest-assured.version>
60-
<cucumber-java.version>7.15.0</cucumber-java.version>
61-
<cucumber-spring.version>7.15.0</cucumber-spring.version>
62-
<cucumber-testng.version>7.15.0</cucumber-testng.version>
58+
<json.version>20250517</json.version>
59+
<rest-assured.version>5.5.0</rest-assured.version>
60+
<cucumber-java.version>7.22.0</cucumber-java.version>
61+
<cucumber-spring.version>7.22.0</cucumber-spring.version>
62+
<cucumber-testng.version>7.22.0</cucumber-testng.version>
6363
<logback.version>1.5.13</logback.version>
64-
<gherkin.version>28.0.0</gherkin.version>
64+
<gherkin.version>32.1.1</gherkin.version>
6565
<commons-io.version>2.15.1</commons-io.version>
6666
<assertj-core.version>3.23.1</assertj-core.version>
6767
<extentreports-cucumber7-adapter.version>1.14.0</extentreports-cucumber7-adapter.version>
68-
<allure-cucumber7-jvm.version>2.25.0</allure-cucumber7-jvm.version>
69-
<ngwebdriver.version>1.2</ngwebdriver.version>
70-
<selenide.version>7.1.0</selenide.version>
71-
<selenium-java.version>4.18.1</selenium-java.version>
72-
<selenium-server.version>4.0.0-alpha-2</selenium-server.version>
68+
<allure-cucumber7-jvm.version>2.29.1</allure-cucumber7-jvm.version>
69+
<selenium-java.version>4.33.0</selenium-java.version>
7370
<maven-remote-resources-plugin.version>1.7.0</maven-remote-resources-plugin.version>
7471
<maven.surefire.plugin.version>3.1.2</maven.surefire.plugin.version>
7572
<surefire.testng.version>3.2.3</surefire.testng.version>
@@ -130,11 +127,6 @@
130127
<artifactId>allure-cucumber7-jvm</artifactId>
131128
<version>${allure-cucumber7-jvm.version}</version>
132129
</dependency>
133-
<dependency>
134-
<groupId>com.paulhammant</groupId>
135-
<artifactId>ngwebdriver</artifactId>
136-
<version>${ngwebdriver.version}</version>
137-
</dependency>
138130
<dependency>
139131
<groupId>ch.qos.logback</groupId>
140132
<artifactId>logback-classic</artifactId>

wikipedia/pom.xml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,11 @@
1616
<artifactId>common</artifactId>
1717
<version>1.0-SNAPSHOT</version>
1818
</dependency>
19-
<dependency>
20-
<groupId>com.codeborne</groupId>
21-
<artifactId>selenide</artifactId>
22-
<version>${selenide.version}</version>
23-
</dependency>
2419
<dependency>
2520
<groupId>org.seleniumhq.selenium</groupId>
2621
<artifactId>selenium-java</artifactId>
2722
<version>${selenium-java.version}</version>
2823
</dependency>
29-
<dependency>
30-
<groupId>org.seleniumhq.selenium</groupId>
31-
<artifactId>selenium-server</artifactId>
32-
<version>${selenium-server.version}</version>
33-
</dependency>
3424
</dependencies>
3525

3626
<build>
@@ -52,8 +42,7 @@
5242
</dependency>
5343
</dependencies>
5444
</plugin>
55-
56-
</plugins>
45+
</plugins>
5746
</build>
5847

5948
</project>

wikipedia/src/test/java/com/cmccarthy/ui/step/Hooks.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import com.cmccarthy.common.utils.LogManager;
55
import com.cmccarthy.ui.config.WikipediaAbstractTestDefinition;
66
import com.cmccarthy.ui.utils.DriverManager;
7-
import com.codeborne.selenide.WebDriverRunner;
87
import io.cucumber.java.After;
98
import io.cucumber.java.Before;
109
import io.cucumber.java.Scenario;
@@ -17,8 +16,6 @@
1716
public class Hooks extends WikipediaAbstractTestDefinition {
1817
@Autowired
1918
private LogManager logManager;
20-
private static final Object lock = new Object();
21-
private static boolean initialized = false;
2219
@Autowired
2320
private HookUtil hookUtil;
2421
@Autowired
@@ -28,23 +25,15 @@ public class Hooks extends WikipediaAbstractTestDefinition {
2825
public void beforeScenario(Scenario scenario) throws IOException {
2926
String filename = scenario.getName().replaceAll("\\s+", "_");
3027
logManager.createNewLogger(filename);
31-
32-
synchronized (lock) {
33-
if (!initialized) {
34-
if (!driverManager.isDriverExisting()) {
35-
driverManager.downloadDriver();
36-
}
37-
initialized = true;
38-
}
39-
}
4028
driverManager.createDriver();
4129
}
4230

4331
@After
4432
public void afterScenario(Scenario scenario) {
4533
hookUtil.endOfTest(scenario);
4634
if (driverManager.getDriver() != null) {
47-
WebDriverRunner.closeWebDriver();
35+
driverManager.getDriver().quit();
36+
driverManager.setDriver(null);
4837
}
4938
}
5039
}

wikipedia/src/test/java/com/cmccarthy/ui/utils/DriverHelper.java

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717
@SuppressWarnings("unused")
1818
public class DriverHelper {
1919

20-
// @Bean
21-
// public DriverHelper driverHelper(){
22-
// return new DriverHelper();
23-
// }
24-
2520
private final Logger logger = LoggerFactory.getLogger(DriverHelper.class);
2621
private DriverManager driverManager;
2722
@Autowired
@@ -32,7 +27,7 @@ public class DriverHelper {
3227
*/
3328
public void sendKeys(WebElement element, String value) {
3429
if (value != null) {
35-
if (value.length() > 0) {
30+
if (!value.isEmpty()) {
3631
clear(element);
3732
element.sendKeys(value);
3833
} else {
@@ -44,7 +39,7 @@ public void sendKeys(WebElement element, String value) {
4439
/**
4540
* Clicks on an element by WebElement
4641
*/
47-
@Retryable(maxAttempts = 3, backoff = @Backoff(delay = 500), include = {RetryException.class})
42+
@Retryable(maxAttempts = 3, backoff = @Backoff(delay = 500), retryFor = {RetryException.class})
4843
public void click(WebElement element) throws NoSuchFieldException {
4944
try {
5045
driverWait.waitForElementToLoad(element);
@@ -58,7 +53,7 @@ public void click(WebElement element) throws NoSuchFieldException {
5853
/**
5954
* Clicks on an element by Locator
6055
*/
61-
@Retryable(maxAttempts = 3, backoff = @Backoff(delay = 500), include = {RetryException.class})
56+
@Retryable(maxAttempts = 3, backoff = @Backoff(delay = 500), retryFor = {RetryException.class})
6257
public void click(By locator) throws NoSuchFieldException {
6358
try {
6459
driverWait.waitForElementToLoad(locator);
@@ -72,7 +67,7 @@ public void click(By locator) throws NoSuchFieldException {
7267
/**
7368
* Clicks on an element by Locator
7469
*/
75-
@Retryable(maxAttempts = 3, backoff = @Backoff(delay = 500), include = {RetryException.class})
70+
@Retryable(maxAttempts = 3, backoff = @Backoff(delay = 500), retryFor = { RetryException.class })
7671
public void rightClick(By locator) throws NoSuchFieldException {
7772
driverWait.waitForElementToLoad(locator);
7873
final WebElement element = driverManager.getDriver().findElement(locator);
@@ -81,25 +76,25 @@ public void rightClick(By locator) throws NoSuchFieldException {
8176
builder.moveToElement(element).contextClick(element);
8277
builder.perform();
8378
} catch (Exception ser) {
84-
logger.warn("Could not click on the element : " + element);
79+
logger.warn("Could not right click on the element : " + element);
8580
throw new RetryException("Could not click on the element : " + element);
8681
}
8782
}
8883

89-
@Retryable(maxAttempts = 3, backoff = @Backoff(delay = 500), include = {RetryException.class})
84+
@Retryable(maxAttempts = 3, backoff = @Backoff(delay = 500), retryFor = {RetryException.class})
9085
public void scrollElementIntoView(WebElement element) {
9186
try {
9287
driverManager.getJSExecutor().executeScript("arguments[0].scrollIntoView(true);", element);
9388
} catch (Exception ignored) {
94-
logger.warn("Could not click on the element : " + element);
89+
logger.warn("Could not scroll the element into view" + element);
9590
throw new RetryException("Could not click on the element : " + element);
9691
}
9792
}
9893

9994
/**
10095
* Clicks on an element by WebElement
10196
*/
102-
@Retryable(maxAttempts = 3, backoff = @Backoff(delay = 500), include = {RetryException.class})
97+
@Retryable(maxAttempts = 3, backoff = @Backoff(delay = 500), retryFor = {RetryException.class})
10398
public void rightClick(WebElement element) throws NoSuchFieldException {
10499
driverWait.waitForElementToLoad(element);
105100

@@ -117,23 +112,23 @@ public void rightClick(WebElement element) throws NoSuchFieldException {
117112
* Clicks on an element using Actions
118113
*/
119114

120-
@Retryable(maxAttempts = 3, backoff = @Backoff(delay = 500), include = {RetryException.class})
115+
@Retryable(maxAttempts = 3, backoff = @Backoff(delay = 500), retryFor = {RetryException.class})
121116
public void clickAction(WebElement element) throws NoSuchFieldException {
122117
driverWait.waitForElementToLoad(element);
123118
try {
124119
final Actions builder = new Actions(driverManager.getDriver());
125120
builder.moveToElement(element).click(element);
126121
builder.perform();
127122
} catch (Exception ser) {
128-
logger.warn("Could not click on the element");
123+
logger.warn("Could not click action on the element");
129124
throw new RetryException("Could not click on the element : " + element);
130125
}
131126
}
132127

133128
/**
134129
* Clicks on an element using Actions
135130
*/
136-
@Retryable(maxAttempts = 3, backoff = @Backoff(delay = 500), include = {RetryException.class})
131+
@Retryable(maxAttempts = 3, backoff = @Backoff(delay = 500), retryFor = {RetryException.class})
137132
public void clickAction(By locator) throws NoSuchFieldException {
138133
driverWait.waitForElementToLoad(locator);
139134

@@ -143,7 +138,7 @@ public void clickAction(By locator) throws NoSuchFieldException {
143138
builder.moveToElement(element).click(element);
144139
builder.perform();
145140
} catch (Exception ser) {
146-
logger.warn("Could not click on the element");
141+
logger.warn("Could not click action on the element");
147142
throw new RetryException("Could not click on the element : " + element);
148143
}
149144
}

0 commit comments

Comments
 (0)