Skip to content

Commit c82d550

Browse files
Merge pull request #301 from eliasnogueira/latest-updates
Latest updates
2 parents 6582bc4 + eb2fd86 commit c82d550

File tree

8 files changed

+41
-23
lines changed

8 files changed

+41
-23
lines changed

README.MD

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ The browser used in the test is placed on the `browser` property in the `general
105105

106106
##### Local Suite
107107

108-
It's the same as the Local Execution, where the difference is that the browser is taken from the TestNG suite file instead of the `general.properties`
108+
It's the same as the Local Execution, where the difference is that the browser is taken from the TestNG suite file
109+
instead of the `general.properties`
109110
file, enabling you to run multi-browser test approach locally.
110111

111112
##### Testcontainers
@@ -118,6 +119,7 @@ the container based on the browser set in the `browser` property. Currently, Tes
118119
Firefox.
119120

120121
Example
122+
121123
```shell
122124
mvn test -Pweb-execution -Dtarget=testcontainers -Dbrowser=chrome
123125
```
@@ -153,7 +155,8 @@ Each browser is an `enum`, and each enum implements four methods:
153155
* `createDriver()`: creates the browser instance for the remote execution
154156
* `getOptions()`: creates a new browser `Options` setting some specific configurations, and it's used for the remote
155157
executions using the Selenium Grid
156-
* `createTestContainerDriver()` : Creates selenium grid lightweight test container in Standalone mode with Chrome/Firefox/Edge browser support.
158+
* `createTestContainerDriver()` : Creates selenium grid lightweight test container in Standalone mode with
159+
Chrome/Firefox/Edge browser support.
157160

158161
You can see that the `createLocalDriver()` method use the `getOptions()` to get specific browser configurations, as
159162
starting the browser maximized and others.
@@ -211,7 +214,8 @@ factory [BookingDataFactory](https://github.com/eliasnogueira/selenium-java-lean
211214

212215
The parallel test execution is based on
213216
the [parallel tests](https://testng.org/doc/documentation-main.html#parallel-tests)
214-
feature on TestNG. This is used by `selenium-grid.xml` test suite file which has the `parallel="tests"` attribute and value,
217+
feature on TestNG. This is used by `selenium-grid.xml` test suite file which has the `parallel="tests"` attribute and
218+
value,
215219
whereas `test` item inside the test suite will execute in parallel.
216220
The browser in use for each `test` should be defined by a parameter, like:
217221

@@ -237,18 +241,21 @@ Please note that you need to do the following actions before running it in paral
237241

238242
* Docker installed
239243
* Pull the images for Chrome Edge and Firefox - Optional
240-
* Images are pulled if not available and initial test execution will be slow
241-
* `docker pull selenium-standalog-chrome`
242-
* `docker pull selenium-standalog-firefox`
243-
* `docker pull selenium/standalone-edge`
244-
* If you are using a MacBook with either M1 or M2 chip you must check the following experimental feature in Docker Desktop: Settings -> Features in development -> Use Rosetta for x86/amd64 emulation on Apple Silicon
244+
* Images are pulled if not available and initial test execution will be slow
245+
* `docker pull selenium-standalog-chrome`
246+
* `docker pull selenium-standalog-firefox`
247+
* `docker pull selenium/standalone-edge`
248+
* If you are using a MacBook with either M1 or M2 chip you must check the following experimental feature in Docker
249+
Desktop: Settings -> Features in development -> Use Rosetta for x86/amd64 emulation on Apple Silicon
245250
* Pay attention to the `grid/config.toml` file that has comments for each specific SO
246251
* Start the Grid by running the following command inside the `grid` folder
247252
* `docker-compose up`
248253
* Run the project using the following command
254+
249255
```shell
250256
mvn test -Pweb-execution -Dsuite=selenium-grid -Dtarget=selenium-grid -Dheadless=true
251257
```
258+
252259
* Open the [Selenium Grid] page to see the node status
253260

254261
### Configuration files
@@ -295,7 +302,7 @@ To execute this suite, via the command line you can call the parameter `-P` and
295302
Eg: executing the multi_browser suite
296303

297304
``` bash
298-
mvn test -Pweb-execution -Dtestng.dtd.http=true
305+
mvn test -Pweb-execution
299306
```
300307

301308
If you have more than one suite on _src/test/resources/suites_ folder you can parameterize the xml file name.
@@ -333,7 +340,7 @@ To do this you need:
333340
* Use `-Dsuite=suite_name` to call the suite
334341

335342
````bash
336-
mvn test -Pweb-execution -Dsuite=parallel
343+
mvn test -Pweb-execution -Dsuite=suite_name
337344
````
338345

339346
### Pipeline as a code

grid/config.toml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@ configs = [
66
"selenium/standalone-chrome:latest", "{\"browserName\": \"chrome\"}"
77
]
88

9+
host-config-keys = ["Binds"]
10+
911
# URL for connecting to the docker daemon
10-
# host.docker.internal works for macOS and Windows.
11-
# Linux could use --net=host in the `docker run` instruction or 172.17.0.1 in the URI below.
12-
# To have Docker listening through tcp on macOS, install socat and run the following command
13-
# socat -4 TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock
12+
# Most simple approach, leave it as http://127.0.0.1:2375, and mount /var/run/docker.sock.
13+
# 127.0.0.1 is used because internally the container uses socat when /var/run/docker.sock is mounted
14+
# If var/run/docker.sock is not mounted:
15+
# Windows: make sure Docker Desktop exposes the daemon via tcp, and use http://host.docker.internal:2375.
16+
# macOS: install socat and run the following command, socat -4 TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock,
17+
# then use http://host.docker.internal:2375.
18+
# Linux: varies from machine to machine, please mount /var/run/docker.sock. If this does not work, please create an issue.
19+
1420
url = "http://host.docker.internal:2375"
1521
# Docker image used for video recording
1622
video-image = "selenium/video:latest"

grid/docker-compose.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
version: "3"
21
services:
32
node-docker:
43
image: selenium/node-docker:latest
54
volumes:
65
- ./assets:/opt/selenium/assets
76
- ./config.toml:/opt/bin/config.toml
7+
- ~/Downloads:/home/seluser/Downloads
8+
- /var/run/docker.sock:/var/run/docker.sock
89
depends_on:
910
- selenium-hub
1011
environment:
@@ -18,4 +19,4 @@ services:
1819
ports:
1920
- "4442:4442"
2021
- "4443:4443"
21-
- "4444:4444"
22+
- "4444:4444"

pom.xml

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

77
<groupId>com.eliasnogueira</groupId>
88
<artifactId>selenium-java-lean-test-architecture</artifactId>
9-
<version>3.4.6</version>
9+
<version>3.4.7</version>
1010

1111
<scm>
1212
<connection>scm:[email protected]:eliasnogueira/selenium-java-lean-test-architecture.git</connection>
@@ -25,7 +25,7 @@
2525
<selenium.version>4.25.0</selenium.version>
2626
<testng.version>7.10.2</testng.version>
2727
<assertj.version>3.26.3</assertj.version>
28-
<datafaker.version>2.4.0</datafaker.version>
28+
<datafaker.version>2.4.1</datafaker.version>
2929
<log4j.version>2.23.1</log4j.version>
3030
<owner.version>1.0.12</owner.version>
3131
<allure.version>2.29.0</allure.version>
@@ -34,7 +34,7 @@
3434
<allure.cmd.download.url>
3535
https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline
3636
</allure.cmd.download.url>
37-
<testcontainers.selenium.version>1.20.2</testcontainers.selenium.version>
37+
<testcontainers.selenium.version>1.20.3</testcontainers.selenium.version>
3838

3939
<!-- Vulnerability temp libs-->
4040
<commons-compress.version>1.27.1</commons-compress.version>

src/main/java/com/eliasnogueira/config/ConfigurationManager.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,3 @@ public static Configuration configuration() {
3535
return ConfigCache.getOrCreate(Configuration.class);
3636
}
3737
}
38-

src/main/java/com/eliasnogueira/driver/BrowserFactory.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@
3939
import org.testcontainers.containers.BrowserWebDriverContainer;
4040

4141
import static com.eliasnogueira.config.ConfigurationManager.configuration;
42-
import static com.eliasnogueira.data.changeless.BrowserData.*;
42+
import static com.eliasnogueira.data.changeless.BrowserData.CHROME_HEADLESS;
43+
import static com.eliasnogueira.data.changeless.BrowserData.DISABLE_INFOBARS;
44+
import static com.eliasnogueira.data.changeless.BrowserData.DISABLE_NOTIFICATIONS;
45+
import static com.eliasnogueira.data.changeless.BrowserData.GENERIC_HEADLESS;
46+
import static com.eliasnogueira.data.changeless.BrowserData.REMOTE_ALLOW_ORIGINS;
47+
import static com.eliasnogueira.data.changeless.BrowserData.START_MAXIMIZED;
4348
import static java.lang.Boolean.TRUE;
4449

4550
public enum BrowserFactory {

src/main/java/com/eliasnogueira/enums/RoomType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ public static RoomType getRandom() {
4545
public String get() {
4646
return this.value;
4747
}
48-
}
48+
}

src/main/java/com/eliasnogueira/model/Booking.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,4 @@ public Booking build() {
7878
return new Booking(email, country, password, dailyBudget, newsletter, roomType, roomDescription);
7979
}
8080
}
81-
}
81+
}

0 commit comments

Comments
 (0)