Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ The browser used in the test is placed on the `browser` property in the `general

##### Local Suite

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`
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`
file, enabling you to run multi-browser test approach locally.

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

Example

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

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

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

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

* Docker installed
* Pull the images for Chrome Edge and Firefox - Optional
* Images are pulled if not available and initial test execution will be slow
* `docker pull selenium-standalog-chrome`
* `docker pull selenium-standalog-firefox`
* `docker pull selenium/standalone-edge`
* 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
* Images are pulled if not available and initial test execution will be slow
* `docker pull selenium-standalog-chrome`
* `docker pull selenium-standalog-firefox`
* `docker pull selenium/standalone-edge`
* 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
* Pay attention to the `grid/config.toml` file that has comments for each specific SO
* Start the Grid by running the following command inside the `grid` folder
* `docker-compose up`
* Run the project using the following command

```shell
mvn test -Pweb-execution -Dsuite=selenium-grid -Dtarget=selenium-grid -Dheadless=true
```

* Open the [Selenium Grid] page to see the node status

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

``` bash
mvn test -Pweb-execution -Dtestng.dtd.http=true
mvn test -Pweb-execution
```

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

````bash
mvn test -Pweb-execution -Dsuite=parallel
mvn test -Pweb-execution -Dsuite=suite_name
````

### Pipeline as a code
Expand Down
14 changes: 10 additions & 4 deletions grid/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ configs = [
"selenium/standalone-chrome:latest", "{\"browserName\": \"chrome\"}"
]

host-config-keys = ["Binds"]

# URL for connecting to the docker daemon
# host.docker.internal works for macOS and Windows.
# Linux could use --net=host in the `docker run` instruction or 172.17.0.1 in the URI below.
# To have Docker listening through tcp on macOS, install socat and run the following command
# socat -4 TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock
# Most simple approach, leave it as http://127.0.0.1:2375, and mount /var/run/docker.sock.
# 127.0.0.1 is used because internally the container uses socat when /var/run/docker.sock is mounted
# If var/run/docker.sock is not mounted:
# Windows: make sure Docker Desktop exposes the daemon via tcp, and use http://host.docker.internal:2375.
# macOS: install socat and run the following command, socat -4 TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock,
# then use http://host.docker.internal:2375.
# Linux: varies from machine to machine, please mount /var/run/docker.sock. If this does not work, please create an issue.

url = "http://host.docker.internal:2375"
# Docker image used for video recording
video-image = "selenium/video:latest"
Expand Down
5 changes: 3 additions & 2 deletions grid/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
version: "3"
services:
node-docker:
image: selenium/node-docker:latest
volumes:
- ./assets:/opt/selenium/assets
- ./config.toml:/opt/bin/config.toml
- ~/Downloads:/home/seluser/Downloads
- /var/run/docker.sock:/var/run/docker.sock
depends_on:
- selenium-hub
environment:
Expand All @@ -18,4 +19,4 @@ services:
ports:
- "4442:4442"
- "4443:4443"
- "4444:4444"
- "4444:4444"
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.eliasnogueira</groupId>
<artifactId>selenium-java-lean-test-architecture</artifactId>
<version>3.4.6</version>
<version>3.4.7</version>

<scm>
<connection>scm:[email protected]:eliasnogueira/selenium-java-lean-test-architecture.git</connection>
Expand All @@ -25,7 +25,7 @@
<selenium.version>4.25.0</selenium.version>
<testng.version>7.10.2</testng.version>
<assertj.version>3.26.3</assertj.version>
<datafaker.version>2.4.0</datafaker.version>
<datafaker.version>2.4.1</datafaker.version>
<log4j.version>2.23.1</log4j.version>
<owner.version>1.0.12</owner.version>
<allure.version>2.29.0</allure.version>
Expand All @@ -34,7 +34,7 @@
<allure.cmd.download.url>
https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline
</allure.cmd.download.url>
<testcontainers.selenium.version>1.20.2</testcontainers.selenium.version>
<testcontainers.selenium.version>1.20.3</testcontainers.selenium.version>

<!-- Vulnerability temp libs-->
<commons-compress.version>1.27.1</commons-compress.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,3 @@ public static Configuration configuration() {
return ConfigCache.getOrCreate(Configuration.class);
}
}

7 changes: 6 additions & 1 deletion src/main/java/com/eliasnogueira/driver/BrowserFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@
import org.testcontainers.containers.BrowserWebDriverContainer;

import static com.eliasnogueira.config.ConfigurationManager.configuration;
import static com.eliasnogueira.data.changeless.BrowserData.*;
import static com.eliasnogueira.data.changeless.BrowserData.CHROME_HEADLESS;
import static com.eliasnogueira.data.changeless.BrowserData.DISABLE_INFOBARS;
import static com.eliasnogueira.data.changeless.BrowserData.DISABLE_NOTIFICATIONS;
import static com.eliasnogueira.data.changeless.BrowserData.GENERIC_HEADLESS;
import static com.eliasnogueira.data.changeless.BrowserData.REMOTE_ALLOW_ORIGINS;
import static com.eliasnogueira.data.changeless.BrowserData.START_MAXIMIZED;
import static java.lang.Boolean.TRUE;

public enum BrowserFactory {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/eliasnogueira/enums/RoomType.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ public static RoomType getRandom() {
public String get() {
return this.value;
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/eliasnogueira/model/Booking.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ public Booking build() {
return new Booking(email, country, password, dailyBudget, newsletter, roomType, roomDescription);
}
}
}
}