Skip to content

Commit c366858

Browse files
authored
Support Selenium WebDriver 4 (#174)
* fix: Upgraded Selenium WebDriver to 4.1.1 and also fixed code smells from Sonar analysis. * fix: Updated workflows to run on all supported branches. * fix: Updated config to execute BS tests on BS instead of local. * fix: Correct Config was not picked when multiple testng yaml was run simultaneuosly. * fix: Upgraded Selenium Grid version to 4.1.1, also turned off parallel runs. * fix: Removed failing IE test and updated README.
1 parent fc6f836 commit c366858

File tree

9 files changed

+46
-81
lines changed

9 files changed

+46
-81
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ name: "CodeQL"
1313

1414
on:
1515
push:
16-
branches: [master]
17-
pull_request:
18-
branches: [master]
16+
branches:
17+
- master
18+
- main
19+
- release
20+
- issue-*
1921
schedule:
20-
- cron: "30 10 * * 6"
22+
- cron: "0 21 * * *"
2123

2224
jobs:
2325
analyze:
@@ -31,7 +33,7 @@ jobs:
3133
strategy:
3234
fail-fast: false
3335
matrix:
34-
language: ["java"]
36+
language: [ "java" ]
3537
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
3638
# Learn more about CodeQL language support at https://git.io/codeql-language-support
3739

.github/workflows/test.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
name: Test coteafs-selenium project
22

33
on:
4-
pull_request:
5-
types:
6-
- opened
7-
- synchronize
8-
- reopened
94
push:
105
branches:
116
- master
@@ -72,7 +67,7 @@ jobs:
7267
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
7368
sudo apt-get update
7469
sudo apt-get install google-chrome-stable
75-
docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome:3.141.59
70+
docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome:4.1.1
7671
7772
- name: Test execution
7873
env:
@@ -127,8 +122,4 @@ jobs:
127122
env:
128123
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
129124
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
130-
run: |
131-
mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
132-
-Dsonar.projectKey=com.github.wasiqb.coteafs:selenium \
133-
-DskipTests \
134-
-Dcheckstyle.skip
125+
run: mvn -B sonar:sonar -DskipTests -Dcheckstyle.skip

.talismanrc

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

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
## :question: What is this Framework about?
2727

2828
This is a Selenium WebDriver wrapper Framework which enables robust, maintainable and easy to write test scripts. _**It
29-
supports the latest stable Selenium WebDriver 3.141.59**_.
29+
supports the latest stable Selenium WebDriver 4.1.1**_.
3030

3131
## :bulb: What features do this framework offer?
3232

3333
Some key features which this framework offers are as follows:
3434

35-
:point_right: Latest stable Selenium WebDriver 3.141.59.
35+
:point_right: Latest stable Selenium WebDriver 4.1.1
3636

3737
:point_right: Minimal learning curve.
3838

@@ -87,7 +87,7 @@ Config file is by default searched in `src/test/resources` folder. The name of t
8787
as `selenium-config.yaml`. But the same can be overridden by using System property `coteafs.selenium.config` where you
8888
can specify the new config file for the test.
8989

90-
#### Sample Config file
90+
### Sample Config file
9191

9292
`src/test/resources/selenium-config.yaml`
9393

@@ -167,7 +167,7 @@ site.
167167
168168
> Remember, `BrowserPage` class needs to be extended for every page and also a flavour of inheritance can be added as per requirement.
169169

170-
#### Sample Page object
170+
### Sample Page object
171171

172172
```java
173173
package com.github.wasiqb.coteafs.selenium.pages;
@@ -210,7 +210,7 @@ place.
210210
> For every page action you need to extend `AbstractPageAction`. Since it is a generic class, you need to pass the action class name as it's generic type.
211211
> Also, `perform` method needs to be implemented for every action class.
212212

213-
#### Sample page action
213+
### Sample page action
214214

215215
```java
216216
package com.github.wasiqb.coteafs.selenium.pages.action;
@@ -252,7 +252,7 @@ public class LoginPageAction extends AbstractPageAction<LoginPageAction> {
252252
Test which are written using this framework are slightly different than usual. In the tests, Page actions is used
253253
instead of page objects. This can be demonstrated as shown below:
254254

255-
#### Sample Test
255+
### Sample Test
256256

257257
> Every test class extends `BrowserTest` class.
258258

lombok.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
config.stopBubbling = true
12
lombok.addLombokGeneratedAnnotation = true

pom.xml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<parent>
1111
<groupId>com.github.wasiqb.coteafs</groupId>
1212
<artifactId>parent</artifactId>
13-
<version>3.8.0</version>
13+
<version>3.9.0</version>
1414
</parent>
1515

1616
<scm>
@@ -25,21 +25,19 @@
2525
</ciManagement>
2626

2727
<properties>
28-
<coteafs.data.version>1.4.0</coteafs.data.version>
28+
<coteafs.data.version>1.5.0</coteafs.data.version>
2929
<coteafs.error.version>1.15.0</coteafs.error.version>
3030
<log4j.version>2.17.1</log4j.version>
31-
<coteafs.listener.version>3.3.0</coteafs.listener.version>
32-
<selenium-version>3.141.59</selenium-version>
31+
<coteafs.listener.version>3.4.0</coteafs.listener.version>
32+
<selenium-version>4.1.1</selenium-version>
3333
<commons.io.version>2.11.0</commons.io.version>
3434
<webdrivermanager-version>5.0.3</webdrivermanager-version>
3535
<faker.version>1.0.2</faker.version>
3636
<commons.text.version>1.9</commons.text.version>
3737
<recorder.version>0.7.7.0</recorder.version>
3838
<lombok.version>1.18.22</lombok.version>
3939
<jackson.version>2.13.1</jackson.version>
40-
<sonar.organization>wasiqb-github</sonar.organization>
41-
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
42-
<sonar.coverage.jacoco.xmlReportPaths>target/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
40+
<sonar.projectKey>com.github.wasiqb.coteafs:selenium</sonar.projectKey>
4341
</properties>
4442

4543
<dependencies>

src/main/java/com/github/wasiqb/coteafs/selenium/config/ConfigUtil.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
* @since Aug 9, 2018 8:23:23 PM
2323
*/
2424
public final class ConfigUtil {
25-
private static BrowserSetting setting;
26-
2725
/**
2826
* @param browserName Browser setting name.
2927
*
@@ -33,11 +31,8 @@ public final class ConfigUtil {
3331
* @since Aug 9, 2018 8:39:04 PM
3432
*/
3533
public static BrowserSetting appSetting (final String browserName) {
36-
if (setting == null) {
37-
setting = DataSource.parse (SeleniumConfig.class)
38-
.getBrowserSetting (browserName);
39-
}
40-
return setting;
34+
return DataSource.parse (SeleniumConfig.class)
35+
.getBrowserSetting (browserName);
4136
}
4237

4338
private ConfigUtil () {

src/test/resources/selenium-config.yaml

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ browsers:
4444
# version: 2.14
4545
# exe_url: https://driver/download/url
4646
grid:
47+
browser: REMOTE
4748
<<: *default_browser
4849
headless_mode: true
4950
remote:
@@ -55,25 +56,27 @@ browsers:
5556
version: 77.0.3865.75
5657
platform: LINUX
5758
bs_chrome:
59+
browser: REMOTE
5860
<<: *default_browser
5961
remote:
60-
user_id: ${CLOUD_USER}
61-
password: ${CLOUD_KEY}
62+
user_id: ${env:CLOUD_USER}
63+
password: ${env:CLOUD_KEY}
6264
protocol: HTTPS
6365
url: hub-cloud.browserstack.com
6466
source: BROWSERSTACK
6567
capabilities:
6668
browser: Chrome
67-
browser_version: 83.0
69+
browser_version: latest
6870
os: Windows
6971
os_version: 10
7072
resolution: 1024x768
7173
name: Bstack-[Java] Sample Chrome Test
7274
bs_edge:
75+
browser: REMOTE
7376
<<: *default_browser
7477
remote:
75-
user_id: ${CLOUD_USER}
76-
password: ${CLOUD_KEY}
78+
user_id: ${env:CLOUD_USER}
79+
password: ${env:CLOUD_KEY}
7780
protocol: HTTPS
7881
url: hub-cloud.browserstack.com
7982
source: BROWSERSTACK
@@ -85,10 +88,11 @@ browsers:
8588
resolution: 1024x768
8689
name: Bstack-[Java] Sample Edge Test
8790
bs_firefox:
91+
browser: REMOTE
8892
<<: *default_browser
8993
remote:
90-
user_id: ${CLOUD_USER}
91-
password: ${CLOUD_KEY}
94+
user_id: ${env:CLOUD_USER}
95+
password: ${env:CLOUD_KEY}
9296
protocol: HTTPS
9397
url: hub-cloud.browserstack.com
9498
source: BROWSERSTACK
@@ -100,43 +104,45 @@ browsers:
100104
resolution: 1024x768
101105
name: Bstack-[Java] Sample Firefox Test
102106
bs_ie:
107+
browser: REMOTE
103108
<<: *default_browser
104109
remote:
105-
user_id: ${CLOUD_USER}
106-
password: ${CLOUD_KEY}
110+
user_id: ${env:CLOUD_USER}
111+
password: ${env:CLOUD_KEY}
107112
protocol: HTTPS
108113
url: hub-cloud.browserstack.com
109114
source: BROWSERSTACK
110115
capabilities:
111116
browser: IE
112-
browser_version: 11.0
117+
browser_version: latest
113118
os: Windows
114119
os_version: 10
115120
resolution: 1024x768
116121
name: Bstack-[Java] Sample IE Test
117122
bs_safari:
123+
browser: REMOTE
118124
<<: *default_browser
119125
remote:
120-
user_id: ${CLOUD_USER}
121-
password: ${CLOUD_KEY}
126+
user_id: ${env:CLOUD_USER}
127+
password: ${env:CLOUD_KEY}
122128
protocol: HTTPS
123129
url: hub-cloud.browserstack.com
124130
source: BROWSERSTACK
125131
capabilities:
126132
browser: Safari
127-
browser_version: 13.1
133+
browser_version: latest
128134
os: OS X
129-
os_version: Catalina
135+
os_version: Big Sur
130136
resolution: 1024x768
131137
name: Bstack-[Java] Sample Safari Test
132138
sl_chrome:
133139
<<: *default_browser
134-
browser: CHROME
140+
browser: REMOTE
135141
url: http://demo.guru99.com/V4/
136142
headless_mode: true
137143
remote:
138-
user_id: ${CLOUD_USER}
139-
password: ${CLOUD_KEY}
144+
user_id: ${env:CLOUD_USER}
145+
password: ${env:CLOUD_KEY}
140146
protocol: HTTPS
141147
url: ondemand.saucelabs.com
142148
source: SAUCELABS

testng-browserstack.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,3 @@ tests:
2929
- name: com.github.wasiqb.coteafs.selenium.SeleniumTest
3030
includedMethods:
3131
- testLogin
32-
- name: Test BrowserStack IE
33-
parameters: {
34-
test.browser: bs_ie
35-
}
36-
classes:
37-
- name: com.github.wasiqb.coteafs.selenium.SeleniumTest
38-
includedMethods:
39-
- testLogin

0 commit comments

Comments
 (0)