From 046644d0c9003da1b3d66482dbea3f01d43960b5 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Tue, 19 Apr 2022 15:44:59 +0200 Subject: [PATCH 001/191] dependencies update --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index bc10942..63a2c88 100644 --- a/pom.xml +++ b/pom.xml @@ -21,14 +21,14 @@ 3.9.0 1.9.6 - 4.1.2 + 4.1.3 7.5 3.22.0 1.0.2 - 2.17.1 - 5.0.3 + 2.17.2 + 5.1.1 1.0.12 - 2.17.2 + 2.17.3 2.11.2 1.0.0 From 74dd725ec690ddd96491cf54a880e93caf968b83 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Tue, 28 Jun 2022 21:13:46 +0200 Subject: [PATCH 002/191] added allure properties file --- src/test/resources/allure.properties | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/test/resources/allure.properties diff --git a/src/test/resources/allure.properties b/src/test/resources/allure.properties new file mode 100644 index 0000000..80b02dd --- /dev/null +++ b/src/test/resources/allure.properties @@ -0,0 +1 @@ +allure.results.directory=target/allure-results From 8e7bd7fa8c92c56f391b81c279c319a4de5a4997 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Tue, 28 Jun 2022 21:14:09 +0200 Subject: [PATCH 003/191] added empty line in the end of the file for static files --- src/main/resources/log4j2.properties | 2 +- src/test/resources/general.properties | 2 +- src/test/resources/grid.properties | 2 +- src/test/resources/local.properties | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/resources/log4j2.properties b/src/main/resources/log4j2.properties index 6b21586..d41ecde 100644 --- a/src/main/resources/log4j2.properties +++ b/src/main/resources/log4j2.properties @@ -16,4 +16,4 @@ appender.file.layout.pattern=[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - rootLogger.level = info rootLogger.appenderRefs = stdout rootLogger.appenderRef.stdout.ref = STDOUT -rootLogger.appenderRef.file.ref = LOGFILE \ No newline at end of file +rootLogger.appenderRef.file.ref = LOGFILE diff --git a/src/test/resources/general.properties b/src/test/resources/general.properties index 947dd63..c82b3e4 100644 --- a/src/test/resources/general.properties +++ b/src/test/resources/general.properties @@ -11,4 +11,4 @@ timeout = 3 faker.locale = pt-BR # headless mode only for chrome or firefox and local execution -headless = false \ No newline at end of file +headless = false diff --git a/src/test/resources/grid.properties b/src/test/resources/grid.properties index eb20844..90d2540 100644 --- a/src/test/resources/grid.properties +++ b/src/test/resources/grid.properties @@ -1,3 +1,3 @@ # grid url and port grid.url = localhost -grid.port = 4444 \ No newline at end of file +grid.port = 4444 diff --git a/src/test/resources/local.properties b/src/test/resources/local.properties index 07d1868..193bc16 100644 --- a/src/test/resources/local.properties +++ b/src/test/resources/local.properties @@ -1 +1 @@ -browser = chrome \ No newline at end of file +browser = chrome From 498e9385bccb0b58a9c552bcf3cdfda7c629d34b Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Tue, 28 Jun 2022 21:14:26 +0200 Subject: [PATCH 004/191] dependencies update --- pom.xml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 63a2c88..777287e 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-achitecture - 2.0.0 + 2.0.1 scm:git@github.com:eliasnogueira/selenium-java-lean-test-achitecture.git @@ -21,14 +21,14 @@ 3.9.0 1.9.6 - 4.1.3 - 7.5 - 3.22.0 + 4.3.0 + 7.6.0 + 3.23.1 1.0.2 2.17.2 - 5.1.1 + 5.2.1 1.0.12 - 2.17.3 + 2.18.1 2.11.2 1.0.0 @@ -158,9 +158,6 @@ -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar" false - - target/allure-results - From f0024b6a9698ded7e87f314cbaae128781359153 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Tue, 28 Jun 2022 21:23:08 +0200 Subject: [PATCH 005/191] added constant class to remove value duplication --- .../eliasnogueira/data/changeless/BrowserData.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/java/com/eliasnogueira/data/changeless/BrowserData.java diff --git a/src/main/java/com/eliasnogueira/data/changeless/BrowserData.java b/src/main/java/com/eliasnogueira/data/changeless/BrowserData.java new file mode 100644 index 0000000..ec0152b --- /dev/null +++ b/src/main/java/com/eliasnogueira/data/changeless/BrowserData.java @@ -0,0 +1,11 @@ +package com.eliasnogueira.data.changeless; + +public class BrowserData { + + private BrowserData() { + } + + public static final String START_MAXIMIZED = "--start-maximized"; + public static final String DISABLE_INFOBARS = "--disable-infobars"; + public static final String DISABLE_NOTIFICATIONS = "--disable-notifications"; +} From 2c1cd842ece2357b4326cb3325b0d90b3e9a9440 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Tue, 28 Jun 2022 22:06:27 +0200 Subject: [PATCH 006/191] usage of the new constant class --- .../eliasnogueira/driver/BrowserFactory.java | 53 ++----------------- 1 file changed, 5 insertions(+), 48 deletions(-) diff --git a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java index 25ecfb5..65a785d 100644 --- a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java +++ b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java @@ -34,15 +34,14 @@ import org.openqa.selenium.edge.EdgeOptions; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.firefox.FirefoxOptions; -import org.openqa.selenium.ie.InternetExplorerDriver; -import org.openqa.selenium.ie.InternetExplorerOptions; -import org.openqa.selenium.opera.OperaDriver; -import org.openqa.selenium.opera.OperaOptions; import org.openqa.selenium.remote.AbstractDriverOptions; import org.openqa.selenium.safari.SafariDriver; import org.openqa.selenium.safari.SafariOptions; import static com.eliasnogueira.config.ConfigurationManager.configuration; +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.START_MAXIMIZED; import static java.lang.Boolean.TRUE; public enum BrowserFactory { @@ -59,8 +58,8 @@ public WebDriver createDriver() { public ChromeOptions getOptions() { ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.addArguments(START_MAXIMIZED); - chromeOptions.addArguments("--disable-infobars"); - chromeOptions.addArguments("--disable-notifications"); + chromeOptions.addArguments(DISABLE_INFOBARS); + chromeOptions.addArguments(DISABLE_NOTIFICATIONS); chromeOptions.setHeadless(configuration().headless()); return chromeOptions; @@ -115,50 +114,8 @@ public SafariOptions getOptions() { return safariOptions; } - }, OPERA { - @Override - public WebDriver createDriver() { - WebDriverManager.getInstance(DriverManagerType.OPERA).setup(); - - return new OperaDriver(getOptions()); - } - - @Override - public OperaOptions getOptions() { - OperaOptions operaOptions = new OperaOptions(); - operaOptions.addArguments(START_MAXIMIZED); - operaOptions.addArguments("--disable-infobars"); - operaOptions.addArguments("--disable-notifications"); - - if (TRUE.equals(configuration().headless())) - throw new HeadlessNotSupportedException(operaOptions.getBrowserName()); - - return operaOptions; - } - }, IE { - @Override - public WebDriver createDriver() { - WebDriverManager.getInstance(DriverManagerType.IEXPLORER).setup(); - - return new InternetExplorerDriver(getOptions()); - } - - @Override - public InternetExplorerOptions getOptions() { - InternetExplorerOptions internetExplorerOptions = new InternetExplorerOptions(); - internetExplorerOptions.ignoreZoomSettings(); - internetExplorerOptions.takeFullPageScreenshot(); - internetExplorerOptions.introduceFlakinessByIgnoringSecurityDomains(); - - if (TRUE.equals(configuration().headless())) - throw new HeadlessNotSupportedException(internetExplorerOptions.getBrowserName()); - - return internetExplorerOptions; - } }; - private static final String START_MAXIMIZED = "--start-maximized"; - public abstract WebDriver createDriver(); public abstract AbstractDriverOptions getOptions(); From b6c3264269165896f2d76065a7f1d6494e7edf36 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Tue, 28 Jun 2022 22:06:50 +0200 Subject: [PATCH 007/191] moved to a new package --- .../eliasnogueira/data/{ => dynamic}/BookingDataFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/main/java/com/eliasnogueira/data/{ => dynamic}/BookingDataFactory.java (98%) diff --git a/src/main/java/com/eliasnogueira/data/BookingDataFactory.java b/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java similarity index 98% rename from src/main/java/com/eliasnogueira/data/BookingDataFactory.java rename to src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java index 75eb129..eacef8f 100644 --- a/src/main/java/com/eliasnogueira/data/BookingDataFactory.java +++ b/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java @@ -22,7 +22,7 @@ * SOFTWARE. */ -package com.eliasnogueira.data; +package com.eliasnogueira.data.dynamic; import com.github.javafaker.Faker; import com.eliasnogueira.enums.RoomType; From 64c5ce5c49d18771818a139ac7d7c172e81ba5f5 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Tue, 28 Jun 2022 22:07:01 +0200 Subject: [PATCH 008/191] general refactor --- src/test/java/com/eliasnogueira/test/BookRoomWebTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/eliasnogueira/test/BookRoomWebTest.java b/src/test/java/com/eliasnogueira/test/BookRoomWebTest.java index ee2dab1..7b1bfc0 100644 --- a/src/test/java/com/eliasnogueira/test/BookRoomWebTest.java +++ b/src/test/java/com/eliasnogueira/test/BookRoomWebTest.java @@ -24,7 +24,7 @@ package com.eliasnogueira.test; import com.eliasnogueira.BaseWeb; -import com.eliasnogueira.data.BookingDataFactory; +import com.eliasnogueira.data.dynamic.BookingDataFactory; import com.eliasnogueira.model.Booking; import com.eliasnogueira.page.booking.AccountPage; import com.eliasnogueira.page.booking.DetailPage; From bc3eb4577c03afa2b6940dcdf6c36fa413a47439 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Tue, 28 Jun 2022 22:09:08 +0200 Subject: [PATCH 009/191] update actions version --- .github/workflows/test-execution.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index 380c8a6..d747294 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -14,13 +14,13 @@ jobs: image: selenium/standalone-chrome options: --health-cmd '/opt/bin/check-grid.sh' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up JDK 11 - uses: actions/setup-java@v1 + uses: actions/setup-java@v3 with: java-version: 11 - name: Cache Maven packages - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} From 85ee9abb2786d1b4b0e1c4aa3dd31a43db56fc96 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Thu, 30 Jun 2022 21:05:46 +0200 Subject: [PATCH 010/191] added latest tags to the docker images --- grid/config.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grid/config.toml b/grid/config.toml index 9caf674..825693d 100644 --- a/grid/config.toml +++ b/grid/config.toml @@ -2,8 +2,8 @@ # Configs have a mapping between the Docker image to use and the capabilities that need to be matched to # start a container with the given image. configs = [ - "selenium/standalone-firefox:4.0.0-20211013", "{\"browserName\": \"firefox\"}", - "selenium/standalone-chrome:4.0.0-20211013", "{\"browserName\": \"chrome\"}" + "selenium/standalone-firefox:latest", "{\"browserName\": \"firefox\"}", + "selenium/standalone-chrome:latest", "{\"browserName\": \"chrome\"}" ] # URL for connecting to the docker daemon @@ -13,7 +13,7 @@ configs = [ # socat -4 TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock url = "http://host.docker.internal:2375/" # Docker image used for video recording -video-image = "selenium/video:ffmpeg-4.3.1-20211013" +video-image = "selenium/video:ffmpeg-4.3.1-20220628" # Uncomment the following section if you are running the node on a separate VM # Fill out the placeholders with appropriate values From c6ef7455f51ee725e31e9197273dd23e9d2ac853 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Thu, 30 Jun 2022 21:06:03 +0200 Subject: [PATCH 011/191] added latest tags to the docker image --- grid/docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grid/docker-compose.yml b/grid/docker-compose.yml index 104fd1a..53bc7e1 100644 --- a/grid/docker-compose.yml +++ b/grid/docker-compose.yml @@ -4,7 +4,7 @@ version: "3" services: node-docker: - image: selenium/node-docker:4.0.0-20211013 + image: selenium/node-docker:latest volumes: - ./assets:/opt/selenium/assets - ./config.toml:/opt/bin/config.toml @@ -16,7 +16,7 @@ services: - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 selenium-hub: - image: selenium/hub:4.0.0-20211013 + image: selenium/hub:latest container_name: selenium-hub ports: - "4442:4442" From 2e773dc4d9def98c8893f5c87359876cb7f08cf7 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Thu, 30 Jun 2022 21:14:21 +0200 Subject: [PATCH 012/191] replace random by SecureRandom --- .../com/eliasnogueira/data/dynamic/BookingDataFactory.java | 5 +++-- src/main/java/com/eliasnogueira/enums/RoomType.java | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java b/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java index eacef8f..9d627c5 100644 --- a/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java +++ b/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java @@ -26,8 +26,9 @@ import com.github.javafaker.Faker; import com.eliasnogueira.enums.RoomType; + +import java.security.SecureRandom; import java.util.Locale; -import java.util.Random; import com.eliasnogueira.model.Booking; import com.eliasnogueira.model.BookingBuilder; import org.apache.logging.log4j.LogManager; @@ -68,6 +69,6 @@ private String returnDailyBudget() { } private String returnRandomItemOnArray(String[] array) { - return array[(new Random().nextInt(array.length))]; + return array[(new SecureRandom().nextInt(array.length))]; } } diff --git a/src/main/java/com/eliasnogueira/enums/RoomType.java b/src/main/java/com/eliasnogueira/enums/RoomType.java index 80432cc..4d6f4e3 100644 --- a/src/main/java/com/eliasnogueira/enums/RoomType.java +++ b/src/main/java/com/eliasnogueira/enums/RoomType.java @@ -24,7 +24,7 @@ package com.eliasnogueira.enums; -import java.util.Random; +import java.security.SecureRandom; public enum RoomType { @@ -37,7 +37,7 @@ public enum RoomType { } public static RoomType getRandom() { - return values()[new Random().nextInt(values().length)]; + return values()[new SecureRandom().nextInt(values().length)]; } @Override From 82f9ad8c10d130ea2698c97fd807b736584de104 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Thu, 30 Jun 2022 21:20:27 +0200 Subject: [PATCH 013/191] added setup-java distribution --- .github/workflows/test-execution.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index d747294..e68c080 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -19,6 +19,7 @@ jobs: uses: actions/setup-java@v3 with: java-version: 11 + distribution: adopt - name: Cache Maven packages uses: actions/cache@v3 with: From a1f02f6a328f79cb10e5fe59f037148c63304492 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 30 Jun 2022 19:24:11 +0000 Subject: [PATCH 014/191] Bump testng from 7.6.0 to 7.6.1 Bumps [testng](https://github.com/cbeust/testng) from 7.6.0 to 7.6.1. - [Release notes](https://github.com/cbeust/testng/releases) - [Changelog](https://github.com/cbeust/testng/blob/master/CHANGES.txt) - [Commits](https://github.com/cbeust/testng/commits) --- updated-dependencies: - dependency-name: org.testng:testng dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 777287e..39149e7 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ 1.9.6 4.3.0 - 7.6.0 + 7.6.1 3.23.1 1.0.2 2.17.2 From b790d7287f5dc3521befbf51b04acddccddb1196 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Jul 2022 04:04:34 +0000 Subject: [PATCH 015/191] Bump log4j.version from 2.17.2 to 2.18.0 Bumps `log4j.version` from 2.17.2 to 2.18.0. Updates `log4j-api` from 2.17.2 to 2.18.0 Updates `log4j-core` from 2.17.2 to 2.18.0 Updates `log4j-slf4j-impl` from 2.17.2 to 2.18.0 --- updated-dependencies: - dependency-name: org.apache.logging.log4j:log4j-api dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.apache.logging.log4j:log4j-core dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.apache.logging.log4j:log4j-slf4j-impl dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 39149e7..982a3ad 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ 7.6.1 3.23.1 1.0.2 - 2.17.2 + 2.18.0 5.2.1 1.0.12 2.18.1 From bdc312bf94a38a5eb15d1f59f951ac4f212f3ebd Mon Sep 17 00:00:00 2001 From: elias Date: Sat, 20 Aug 2022 19:58:08 +0200 Subject: [PATCH 016/191] dependencies update --- pom.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 982a3ad..cc86fdd 100644 --- a/pom.xml +++ b/pom.xml @@ -5,30 +5,30 @@ 4.0.0 com.eliasnogueira - selenium-java-lean-test-achitecture + selenium-java-lean-test-architecture 2.0.1 - scm:git@github.com:eliasnogueira/selenium-java-lean-test-achitecture.git - scm:git@github.com:eliasnogueira/selenium-java-lean-test-achitecture.git + scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git + scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git UTF-8 UTF-8 11 - 3.0.0-M5 - 3.9.0 + 3.0.0-M7 + 3.10.1 - 1.9.6 - 4.3.0 + 1.9.9.1 + 4.4.0 7.6.1 3.23.1 1.0.2 2.18.0 - 5.2.1 + 5.2.3 1.0.12 - 2.18.1 + 2.19.0 2.11.2 1.0.0 From 861ab40ca3472be08d127b852aa3cf3c0582ab67 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Aug 2022 04:01:07 +0000 Subject: [PATCH 017/191] Bump webdrivermanager from 5.2.3 to 5.3.0 Bumps [webdrivermanager](https://github.com/bonigarcia/webdrivermanager) from 5.2.3 to 5.3.0. - [Release notes](https://github.com/bonigarcia/webdrivermanager/releases) - [Changelog](https://github.com/bonigarcia/webdrivermanager/blob/master/CHANGELOG.md) - [Commits](https://github.com/bonigarcia/webdrivermanager/compare/webdrivermanager-5.2.3...webdrivermanager-5.3.0) --- updated-dependencies: - dependency-name: io.github.bonigarcia:webdrivermanager dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cc86fdd..cf5ec44 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ 3.23.1 1.0.2 2.18.0 - 5.2.3 + 5.3.0 1.0.12 2.19.0 2.11.2 From 019eb1170b7f134e034568a7f483c9f807b1726e Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Tue, 20 Sep 2022 21:57:21 +0200 Subject: [PATCH 018/191] pipeline update --- .github/workflows/test-execution.yml | 10 +++++----- pipeline_as_code/.gitlab-ci.yml | 4 ++-- pipeline_as_code/Jenkinsfile | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index e68c080..29d5f84 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -2,10 +2,10 @@ name: Build and Test on: push: branches: - - master + - main pull_request: branches: - - master + - main jobs: build: runs-on: ubuntu-latest @@ -15,10 +15,10 @@ jobs: options: --health-cmd '/opt/bin/check-grid.sh' steps: - uses: actions/checkout@v3 - - name: Set up JDK 11 + - name: Set up JDK uses: actions/setup-java@v3 with: - java-version: 11 + java-version: 17 distribution: adopt - name: Cache Maven packages uses: actions/cache@v3 @@ -28,5 +28,5 @@ jobs: restore-keys: ${{ runner.os }}-m2 - name: Build with Maven run: mvn -DskipTests -B package --file pom.xml - - name: Run the tests + - name: Run tests run: mvn test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome -Dtestng.dtd.http=true \ No newline at end of file diff --git a/pipeline_as_code/.gitlab-ci.yml b/pipeline_as_code/.gitlab-ci.yml index 7cada51..2cf2579 100644 --- a/pipeline_as_code/.gitlab-ci.yml +++ b/pipeline_as_code/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: maven:3.6.3-jdk-11 +image: maven:3.8.4-openjdk-17 stages: - build @@ -17,4 +17,4 @@ build: test: stage: test script: - - mvn test -Pweb-execution -Dsuite=local -Dtarget=local -Dtestng.dtd.http=true \ No newline at end of file + - mvn test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome -Dtestng.dtd.http=true \ No newline at end of file diff --git a/pipeline_as_code/Jenkinsfile b/pipeline_as_code/Jenkinsfile index 5261f50..f116189 100644 --- a/pipeline_as_code/Jenkinsfile +++ b/pipeline_as_code/Jenkinsfile @@ -12,7 +12,7 @@ node { stage('Test Execution') { try { - sh "'${mvnHome}/bin/mvn' test -Pweb-execution -Dtarget=local -Dsuite=local -Dtestng.dtd.http=true" + sh "'${mvnHome}/bin/mvn' test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome -Dtestng.dtd.http=true" } catch (Exception e) { currentBuild.result = 'FAILURE' } finally { From 185af2e4319edfaf2c5df3e262599cd5198e6fc0 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Tue, 20 Sep 2022 22:00:43 +0200 Subject: [PATCH 019/191] general refactor --- .../data/dynamic/BookingDataFactory.java | 15 +++++++-------- .../eliasnogueira/driver/BrowserFactory.java | 8 ++++---- .../com/eliasnogueira/driver/TargetFactory.java | 17 ++++------------- .../java/com/eliasnogueira/enums/RoomType.java | 7 ++++--- .../com/eliasnogueira/test/BookRoomWebTest.java | 8 ++++---- 5 files changed, 23 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java b/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java index 9d627c5..5740e18 100644 --- a/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java +++ b/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java @@ -38,15 +38,14 @@ public class BookingDataFactory { - private final Faker faker; + private static final Faker faker = new Faker(new Locale(configuration().faker())); private static final Logger logger = LogManager.getLogger(BookingDataFactory.class); - public BookingDataFactory() { - faker = new Faker(new Locale(configuration().faker())); + private BookingDataFactory() { } - public Booking createBookingData() { - Booking booking = new BookingBuilder(). + public static Booking createBookingData() { + var booking = new BookingBuilder(). email(faker.internet().emailAddress()). country(returnRandomCountry()). password(faker.internet().password()). @@ -60,15 +59,15 @@ public Booking createBookingData() { return booking; } - private String returnRandomCountry() { + private static String returnRandomCountry() { return returnRandomItemOnArray(new String[]{"Belgium", "Brazil", "Netherlands"}); } - private String returnDailyBudget() { + private static String returnDailyBudget() { return returnRandomItemOnArray(new String[]{"$100", "$100 - $499", "$499 - $999", "$999+"}); } - private String returnRandomItemOnArray(String[] array) { + private static String returnRandomItemOnArray(String[] array) { return array[(new SecureRandom().nextInt(array.length))]; } } diff --git a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java index 65a785d..cf46e7e 100644 --- a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java +++ b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java @@ -56,7 +56,7 @@ public WebDriver createDriver() { @Override public ChromeOptions getOptions() { - ChromeOptions chromeOptions = new ChromeOptions(); + var chromeOptions = new ChromeOptions(); chromeOptions.addArguments(START_MAXIMIZED); chromeOptions.addArguments(DISABLE_INFOBARS); chromeOptions.addArguments(DISABLE_NOTIFICATIONS); @@ -74,7 +74,7 @@ public WebDriver createDriver() { @Override public FirefoxOptions getOptions() { - FirefoxOptions firefoxOptions = new FirefoxOptions(); + var firefoxOptions = new FirefoxOptions(); firefoxOptions.addArguments(START_MAXIMIZED); firefoxOptions.setHeadless(configuration().headless()); @@ -90,7 +90,7 @@ public WebDriver createDriver() { @Override public EdgeOptions getOptions() { - EdgeOptions edgeOptions = new EdgeOptions(); + var edgeOptions = new EdgeOptions(); edgeOptions.addArguments(START_MAXIMIZED); edgeOptions.setHeadless(configuration().headless()); @@ -106,7 +106,7 @@ public WebDriver createDriver() { @Override public SafariOptions getOptions() { - SafariOptions safariOptions = new SafariOptions(); + var safariOptions = new SafariOptions(); safariOptions.setAutomaticInspection(false); if (TRUE.equals(configuration().headless())) diff --git a/src/main/java/com/eliasnogueira/driver/TargetFactory.java b/src/main/java/com/eliasnogueira/driver/TargetFactory.java index 36c598c..65d436b 100644 --- a/src/main/java/com/eliasnogueira/driver/TargetFactory.java +++ b/src/main/java/com/eliasnogueira/driver/TargetFactory.java @@ -24,7 +24,6 @@ package com.eliasnogueira.driver; -import com.eliasnogueira.exceptions.TargetNotValidException; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.openqa.selenium.MutableCapabilities; @@ -41,19 +40,11 @@ public class TargetFactory { public WebDriver createInstance(String browser) { Target target = Target.valueOf(configuration().target().toUpperCase()); - WebDriver webdriver; - switch (target) { - case LOCAL: - webdriver = BrowserFactory.valueOf(browser.toUpperCase()).createDriver(); - break; - case REMOTE: - webdriver = createRemoteInstance(BrowserFactory.valueOf(browser.toUpperCase()).getOptions()); - break; - default: - throw new TargetNotValidException(target.toString()); - } - return webdriver; + return switch (target) { + case LOCAL -> BrowserFactory.valueOf(browser.toUpperCase()).createDriver(); + case REMOTE -> createRemoteInstance(BrowserFactory.valueOf(browser.toUpperCase()).getOptions()); + }; } private RemoteWebDriver createRemoteInstance(MutableCapabilities capability) { diff --git a/src/main/java/com/eliasnogueira/enums/RoomType.java b/src/main/java/com/eliasnogueira/enums/RoomType.java index 4d6f4e3..94844d1 100644 --- a/src/main/java/com/eliasnogueira/enums/RoomType.java +++ b/src/main/java/com/eliasnogueira/enums/RoomType.java @@ -25,8 +25,9 @@ package com.eliasnogueira.enums; import java.security.SecureRandom; +import java.util.function.Supplier; -public enum RoomType { +public enum RoomType implements Supplier { SINGLE("Single"), FAMILY("Family"), BUSINESS("Business"); @@ -41,7 +42,7 @@ public static RoomType getRandom() { } @Override - public String toString() { - return value; + public String get() { + return this.value; } } \ No newline at end of file diff --git a/src/test/java/com/eliasnogueira/test/BookRoomWebTest.java b/src/test/java/com/eliasnogueira/test/BookRoomWebTest.java index 7b1bfc0..37fc36f 100644 --- a/src/test/java/com/eliasnogueira/test/BookRoomWebTest.java +++ b/src/test/java/com/eliasnogueira/test/BookRoomWebTest.java @@ -37,9 +37,9 @@ public class BookRoomWebTest extends BaseWeb { @Test(description = "Book a room") public void bookARoom() { - Booking bookingInformation = new BookingDataFactory().createBookingData(); + var bookingInformation = BookingDataFactory.createBookingData(); - AccountPage accountPage = new AccountPage(); + var accountPage = new AccountPage(); accountPage.fillEmail(bookingInformation.getEmail()); accountPage.fillPassword(bookingInformation.getPassword()); accountPage.selectCountry(bookingInformation.getCountry()); @@ -47,11 +47,11 @@ public void bookARoom() { accountPage.clickNewsletter(); accountPage.next(); - RoomPage roomPage = new RoomPage(); + var roomPage = new RoomPage(); roomPage.selectRoomType(bookingInformation.getRoomType()); roomPage.next(); - DetailPage detailPage = new DetailPage(); + var detailPage = new DetailPage(); detailPage.fillRoomDescription(bookingInformation.getRoomDescription()); detailPage.finish(); From 10fb658ee882b62220c8c621e76eb7df0fad8913 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Tue, 20 Sep 2022 22:00:54 +0200 Subject: [PATCH 020/191] license added --- .../data/changeless/BrowserData.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/java/com/eliasnogueira/data/changeless/BrowserData.java b/src/main/java/com/eliasnogueira/data/changeless/BrowserData.java index ec0152b..48117a5 100644 --- a/src/main/java/com/eliasnogueira/data/changeless/BrowserData.java +++ b/src/main/java/com/eliasnogueira/data/changeless/BrowserData.java @@ -1,3 +1,27 @@ +/* + * MIT License + * + * Copyright (c) 2022 Elias Nogueira + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package com.eliasnogueira.data.changeless; public class BrowserData { From cb8d5e60ddea51cbf5e9a4d7cad63cb724e46747 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Tue, 20 Sep 2022 22:01:05 +0200 Subject: [PATCH 021/191] comments removed --- grid/docker-compose.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/grid/docker-compose.yml b/grid/docker-compose.yml index 53bc7e1..498c08a 100644 --- a/grid/docker-compose.yml +++ b/grid/docker-compose.yml @@ -1,6 +1,3 @@ -# To execute this docker-compose yml file use `docker-compose -f docker-compose-v3-dynamic-grid.yml up` -# Add the `-d` flag at the end for detached execution -# To stop the execution, hit Ctrl+C, and then `docker-compose -f docker-compose-v3-dynamic-grid.yml down` version: "3" services: node-docker: From 5883fce162b8d10756d9228f4d8e7f9198369fc1 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Tue, 20 Sep 2022 22:01:16 +0200 Subject: [PATCH 022/191] general refactor --- src/main/java/com/eliasnogueira/driver/DriverManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eliasnogueira/driver/DriverManager.java b/src/main/java/com/eliasnogueira/driver/DriverManager.java index f28102e..680076f 100644 --- a/src/main/java/com/eliasnogueira/driver/DriverManager.java +++ b/src/main/java/com/eliasnogueira/driver/DriverManager.java @@ -24,7 +24,6 @@ package com.eliasnogueira.driver; -import org.openqa.selenium.Capabilities; import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.RemoteWebDriver; @@ -48,10 +47,11 @@ public static void quit() { } public static String getInfo() { - Capabilities cap = ((RemoteWebDriver) DriverManager.getDriver()).getCapabilities(); + var cap = ((RemoteWebDriver) DriverManager.getDriver()).getCapabilities(); String browserName = cap.getBrowserName(); String platform = cap.getPlatformName().toString(); String version = cap.getBrowserVersion(); + return String.format("browser: %s v: %s platform: %s", browserName, version, platform); } } From f087622c8c6e757ed243de7d1664eb6220ceaf94 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Tue, 20 Sep 2022 22:01:31 +0200 Subject: [PATCH 023/191] images moved --- .../example_filed_test_with_report.gif | Bin .../selenium-grid-execution.gif | Bin 2 files changed, 0 insertions(+), 0 deletions(-) rename example_filed_test_with_report.gif => docs/example_filed_test_with_report.gif (100%) rename selenium-grid-execution.gif => docs/selenium-grid-execution.gif (100%) diff --git a/example_filed_test_with_report.gif b/docs/example_filed_test_with_report.gif similarity index 100% rename from example_filed_test_with_report.gif rename to docs/example_filed_test_with_report.gif diff --git a/selenium-grid-execution.gif b/docs/selenium-grid-execution.gif similarity index 100% rename from selenium-grid-execution.gif rename to docs/selenium-grid-execution.gif From bdd02e8b2fb7f0e19c2cfca62f39e71591cb02e2 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Tue, 20 Sep 2022 22:01:56 +0200 Subject: [PATCH 024/191] java 17 adoption --- pom.xml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index cf5ec44..c706cc9 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 2.0.1 + 3.0.0 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -14,9 +14,9 @@ + 17 UTF-8 UTF-8 - 11 3.0.0-M7 3.10.1 @@ -25,7 +25,7 @@ 7.6.1 3.23.1 1.0.2 - 2.18.0 + 2.19.0 5.3.0 1.0.12 2.19.0 @@ -183,8 +183,7 @@ maven-compiler-plugin ${maven-compiler-plugin.version} - ${java-compiler.version} - ${java-compiler.version} + ${java-compiler.version} From 226fbad8d2492513a40a4938b8ff0d51fc98fd44 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Tue, 20 Sep 2022 22:02:04 +0200 Subject: [PATCH 025/191] removed custom exception --- .../exceptions/TargetNotValidException.java | 33 ------------------- 1 file changed, 33 deletions(-) delete mode 100644 src/main/java/com/eliasnogueira/exceptions/TargetNotValidException.java diff --git a/src/main/java/com/eliasnogueira/exceptions/TargetNotValidException.java b/src/main/java/com/eliasnogueira/exceptions/TargetNotValidException.java deleted file mode 100644 index 0dbf149..0000000 --- a/src/main/java/com/eliasnogueira/exceptions/TargetNotValidException.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2021 Elias Nogueira - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.eliasnogueira.exceptions; - -public class TargetNotValidException extends IllegalStateException { - - public TargetNotValidException(String target) { - super(String.format("Target %s not supported. Use either local or gird", target)); - } - -} From 4ca440f2a7667db11e3c0578aab8aed8b907118d Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Tue, 20 Sep 2022 22:05:17 +0200 Subject: [PATCH 026/191] general updates --- README.MD | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/README.MD b/README.MD index 3627c7e..4bcc354 100644 --- a/README.MD +++ b/README.MD @@ -1,19 +1,31 @@ # Lean Test Automation Architecture using Java and Selenium WebDriver [![Actions Status](https://github.com/eliasnogueira/selenium-java-lean-test-achitecture/workflows/Build%20and%20Test/badge.svg)](https://github.com/eliasnogueira/selenium-java-lean-test-achitecture/actions) +**This project delivers to you a complete lean test architecture for your web tests using the best frameworks and practices.** + ## Important information + +### Know issues ```shell This current version has excluded the guava library from WebDriverManager and Allure Environment Writter due to a conflict with the guava version on Selenium 4 ``` -**This project delivers to you a complete lean test architecture for your web tests using the best frameworks and practices.** +### Java versions + +The `main` branch uses Java 17. + +If you want to use Java 11, please take a look at `java-11` branch. + +## Examples + +### Local testing execution example + +![Local testing execution example](docs/example_filed_test_with_report.gif) -Local testing execution example -![Local testing execution example](example_filed_test_with_report.gif) +### Parallel testing execution example with Docker Selenium -Parallel testing execution example with Docker Selenium -![Parallel testing execution example with Docker Selenium](selenium-grid-execution.gif) +![Parallel testing execution example with Docker Selenium](docs/selenium-grid-execution.gif) ## Languages and Frameworks From eb71c2c3b0eed6a83b5d8a43825915936f1b70e5 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Wed, 21 Sep 2022 22:19:03 +0200 Subject: [PATCH 027/191] fix enum translation --- src/main/java/com/eliasnogueira/model/Booking.java | 4 ++-- src/main/java/com/eliasnogueira/page/booking/RoomPage.java | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/eliasnogueira/model/Booking.java b/src/main/java/com/eliasnogueira/model/Booking.java index 812a591..314da58 100644 --- a/src/main/java/com/eliasnogueira/model/Booking.java +++ b/src/main/java/com/eliasnogueira/model/Booking.java @@ -70,8 +70,8 @@ public Boolean getNewsletter() { return this.newsletter; } - public RoomType getRoomType() { - return this.roomType; + public String getRoomType() { + return this.roomType.get(); } public String getRoomDescription() { diff --git a/src/main/java/com/eliasnogueira/page/booking/RoomPage.java b/src/main/java/com/eliasnogueira/page/booking/RoomPage.java index 05763b0..5b14b06 100644 --- a/src/main/java/com/eliasnogueira/page/booking/RoomPage.java +++ b/src/main/java/com/eliasnogueira/page/booking/RoomPage.java @@ -25,7 +25,6 @@ package com.eliasnogueira.page.booking; import com.eliasnogueira.driver.DriverManager; -import com.eliasnogueira.enums.RoomType; import com.eliasnogueira.page.booking.common.NavigationPage; import io.qameta.allure.Step; import org.openqa.selenium.By; @@ -33,7 +32,7 @@ public class RoomPage extends NavigationPage { @Step - public void selectRoomType(RoomType room) { + public void selectRoomType(String room) { DriverManager.getDriver().findElement(By.xpath("//h6[text()='" + room + "']")).click(); } } From 9327247facc1a2a4c1e7e593b48c6987844bb999 Mon Sep 17 00:00:00 2001 From: Erik Pragt Date: Mon, 26 Sep 2022 23:36:52 +1000 Subject: [PATCH 028/191] Migrated to Datafaker. --- pom.xml | 8 ++++---- .../data/dynamic/BookingDataFactory.java | 11 +++-------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index c706cc9..0fa8125 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ 4.4.0 7.6.1 3.23.1 - 1.0.2 + 1.6.0 2.19.0 5.3.0 1.0.12 @@ -58,9 +58,9 @@ - com.github.javafaker - javafaker - ${javafaker.version} + net.datafaker + datafaker + ${datafaker.version} diff --git a/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java b/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java index 5740e18..28e1cde 100644 --- a/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java +++ b/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java @@ -24,10 +24,9 @@ package com.eliasnogueira.data.dynamic; -import com.github.javafaker.Faker; +import net.datafaker.Faker; import com.eliasnogueira.enums.RoomType; -import java.security.SecureRandom; import java.util.Locale; import com.eliasnogueira.model.Booking; import com.eliasnogueira.model.BookingBuilder; @@ -60,14 +59,10 @@ public static Booking createBookingData() { } private static String returnRandomCountry() { - return returnRandomItemOnArray(new String[]{"Belgium", "Brazil", "Netherlands"}); + return faker.options().option("Belgium", "Brazil", "Netherlands"); } private static String returnDailyBudget() { - return returnRandomItemOnArray(new String[]{"$100", "$100 - $499", "$499 - $999", "$999+"}); - } - - private static String returnRandomItemOnArray(String[] array) { - return array[(new SecureRandom().nextInt(array.length))]; + return faker.options().option("$100", "$100 - $499", "$499 - $999", "$999+"); } } From 66a8cf8eaa7bf9ba6941f6ca056083207eb26421 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Tue, 25 Oct 2022 14:34:18 +0200 Subject: [PATCH 029/191] folder rename --- README.MD | 4 ++-- {docs => assets}/example_filed_test_with_report.gif | Bin {docs => assets}/selenium-grid-execution.gif | Bin 3 files changed, 2 insertions(+), 2 deletions(-) rename {docs => assets}/example_filed_test_with_report.gif (100%) rename {docs => assets}/selenium-grid-execution.gif (100%) diff --git a/README.MD b/README.MD index 4bcc354..6137f1c 100644 --- a/README.MD +++ b/README.MD @@ -21,11 +21,11 @@ If you want to use Java 11, please take a look at `java-11` branch. ### Local testing execution example -![Local testing execution example](docs/example_filed_test_with_report.gif) +![Local testing execution example](assets/example_filed_test_with_report.gif) ### Parallel testing execution example with Docker Selenium -![Parallel testing execution example with Docker Selenium](docs/selenium-grid-execution.gif) +![Parallel testing execution example with Docker Selenium](assets/selenium-grid-execution.gif) ## Languages and Frameworks diff --git a/docs/example_filed_test_with_report.gif b/assets/example_filed_test_with_report.gif similarity index 100% rename from docs/example_filed_test_with_report.gif rename to assets/example_filed_test_with_report.gif diff --git a/docs/selenium-grid-execution.gif b/assets/selenium-grid-execution.gif similarity index 100% rename from docs/selenium-grid-execution.gif rename to assets/selenium-grid-execution.gif From 03ca17286f4753e68291d36a4c77ac7d39651942 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Tue, 25 Oct 2022 14:34:35 +0200 Subject: [PATCH 030/191] bump selenium version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0fa8125..c6df414 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ 3.10.1 1.9.9.1 - 4.4.0 + 4.5.3 7.6.1 3.23.1 1.6.0 From 3efc51bb3b6647ecfdfbe017823fda6f21ab1b07 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Tue, 25 Oct 2022 14:34:52 +0200 Subject: [PATCH 031/191] removed unused import --- src/test/java/com/eliasnogueira/test/BookRoomWebTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/com/eliasnogueira/test/BookRoomWebTest.java b/src/test/java/com/eliasnogueira/test/BookRoomWebTest.java index 37fc36f..61dae8e 100644 --- a/src/test/java/com/eliasnogueira/test/BookRoomWebTest.java +++ b/src/test/java/com/eliasnogueira/test/BookRoomWebTest.java @@ -25,7 +25,6 @@ import com.eliasnogueira.BaseWeb; import com.eliasnogueira.data.dynamic.BookingDataFactory; -import com.eliasnogueira.model.Booking; import com.eliasnogueira.page.booking.AccountPage; import com.eliasnogueira.page.booking.DetailPage; import com.eliasnogueira.page.booking.RoomPage; From 891103be760ec4713a9341154ca5d0f64072086b Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Thu, 22 Dec 2022 20:29:06 +0100 Subject: [PATCH 032/191] added local webdriver to differentiate from browserstack --- .../eliasnogueira/driver/BrowserFactory.java | 42 +++++++++++++++++-- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java index cf46e7e..3b53e00 100644 --- a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java +++ b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java @@ -48,12 +48,17 @@ public enum BrowserFactory { CHROME { @Override - public WebDriver createDriver() { + public WebDriver createLocalDriver() { WebDriverManager.getInstance(DriverManagerType.CHROME).setup(); return new ChromeDriver(getOptions()); } + @Override + public WebDriver createDriver() { + return new ChromeDriver(getOptions()); + } + @Override public ChromeOptions getOptions() { var chromeOptions = new ChromeOptions(); @@ -66,12 +71,17 @@ public ChromeOptions getOptions() { } }, FIREFOX { @Override - public WebDriver createDriver() { + public WebDriver createLocalDriver() { WebDriverManager.getInstance(DriverManagerType.FIREFOX).setup(); return new FirefoxDriver(getOptions()); } + @Override + public WebDriver createDriver() { + return new FirefoxDriver(getOptions()); + } + @Override public FirefoxOptions getOptions() { var firefoxOptions = new FirefoxOptions(); @@ -82,12 +92,17 @@ public FirefoxOptions getOptions() { } }, EDGE { @Override - public WebDriver createDriver() { + public WebDriver createLocalDriver() { WebDriverManager.getInstance(DriverManagerType.EDGE).setup(); return new EdgeDriver(getOptions()); } + @Override + public WebDriver createDriver() { + return new EdgeDriver(getOptions()); + } + @Override public EdgeOptions getOptions() { var edgeOptions = new EdgeOptions(); @@ -98,12 +113,17 @@ public EdgeOptions getOptions() { } }, SAFARI { @Override - public WebDriver createDriver() { + public WebDriver createLocalDriver() { WebDriverManager.getInstance(DriverManagerType.SAFARI).setup(); return new SafariDriver(getOptions()); } + @Override + public WebDriver createDriver() { + return new SafariDriver(getOptions()); + } + @Override public SafariOptions getOptions() { var safariOptions = new SafariOptions(); @@ -116,7 +136,21 @@ public SafariOptions getOptions() { } }; + /** + * Used to run local tests where the WebDriverManager will take care of the driver + * @return a new WebDriver instance based on the browser set + */ + public abstract WebDriver createLocalDriver(); + + /** + * Used to run the Browserstack tests + * @return a new WebDriver instance based on the browser set + */ public abstract WebDriver createDriver(); + /** + * + * @return a new AbstractDriverOptions instance based on the browser set + */ public abstract AbstractDriverOptions getOptions(); } From 8524900fd4c2ff9e870d909b1d98da99899c7717 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Thu, 22 Dec 2022 20:29:19 +0100 Subject: [PATCH 033/191] new browserstack test suite --- src/test/resources/suites/browserstack.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/test/resources/suites/browserstack.xml diff --git a/src/test/resources/suites/browserstack.xml b/src/test/resources/suites/browserstack.xml new file mode 100644 index 0000000..b014007 --- /dev/null +++ b/src/test/resources/suites/browserstack.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + From f09e8639cd80473d9c9fe7041bcab189359e3cad Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Thu, 22 Dec 2022 20:29:29 +0100 Subject: [PATCH 034/191] browserstack config file --- browserstack.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 browserstack.yml diff --git a/browserstack.yml b/browserstack.yml new file mode 100644 index 0000000..c582219 --- /dev/null +++ b/browserstack.yml @@ -0,0 +1,26 @@ +# Set BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY as env variables +# instead of adding it here +userName: YOUR_USERNAME +accessKey: YOUR_ACCESS_KEY +buildName: browserstack-build-1 +projectName: BrowserStack Samples +framework: testng +platforms: + - os: OS X + osVersion: Big Sur + browserName: Chrome + browserVersion: latest + - os: Windows + osVersion: 10 + browserName: Edge + browserVersion: latest + - device: Samsung Galaxy S22 Ultra + browserName: chrome + osVersion: 12.0 +parallelsPerPlatform: 1 + +source: testng:sample-master:v1.1 +browserstackLocal: true +debug: false +networkLogs: false +consoleLogs: errors From d527c4a2a4513fc1ccc1143827fbde187be9587f Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Thu, 22 Dec 2022 20:29:43 +0100 Subject: [PATCH 035/191] renamed grid properties --- src/main/java/com/eliasnogueira/config/Configuration.java | 2 +- .../resources/{grid.properties => selenium-grid.properties} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/test/resources/{grid.properties => selenium-grid.properties} (100%) diff --git a/src/main/java/com/eliasnogueira/config/Configuration.java b/src/main/java/com/eliasnogueira/config/Configuration.java index 56b4db9..4322f53 100644 --- a/src/main/java/com/eliasnogueira/config/Configuration.java +++ b/src/main/java/com/eliasnogueira/config/Configuration.java @@ -33,7 +33,7 @@ "system:properties", "classpath:general.properties", "classpath:local.properties", - "classpath:grid.properties"}) + "classpath:selenium-grid.properties"}) public interface Configuration extends Config { @Key("target") diff --git a/src/test/resources/grid.properties b/src/test/resources/selenium-grid.properties similarity index 100% rename from src/test/resources/grid.properties rename to src/test/resources/selenium-grid.properties From 3d037863863e7a4b1459d4b0265a7ee1e736d125 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Thu, 22 Dec 2022 20:30:06 +0100 Subject: [PATCH 036/191] changed comments for the target execution and fake --- src/test/resources/general.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/resources/general.properties b/src/test/resources/general.properties index c82b3e4..3b7c736 100644 --- a/src/test/resources/general.properties +++ b/src/test/resources/general.properties @@ -1,4 +1,4 @@ -# target execution: local or remote +# target execution: local, selenium-grid or browserstack target = local # initial URL @@ -7,7 +7,7 @@ url.base = http://eliasnogueira.com/external/selenium-java-architecture/ # global test timeout timeout = 3 -# javafaker locale +# datafaker locale faker.locale = pt-BR # headless mode only for chrome or firefox and local execution From 70e5683e126a08a35059e3e3b9af4dac01eee7b2 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Thu, 22 Dec 2022 20:30:15 +0100 Subject: [PATCH 037/191] added extra line --- src/test/resources/suites/local.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/suites/local.xml b/src/test/resources/suites/local.xml index fa5f07a..741a2cf 100644 --- a/src/test/resources/suites/local.xml +++ b/src/test/resources/suites/local.xml @@ -8,4 +8,4 @@ - \ No newline at end of file + From 132a55fcaa44fb69b4867d67dbe30c9b50a0a6fc Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Thu, 22 Dec 2022 20:30:34 +0100 Subject: [PATCH 038/191] library update --- pom.xml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index c6df414..a5cce9d 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.0.0 + 3.1.0 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -21,12 +21,12 @@ 3.10.1 1.9.9.1 - 4.5.3 - 7.6.1 + 4.7.2 + 7.7.0 3.23.1 - 1.6.0 + 1.7.0 2.19.0 - 5.3.0 + 5.3.1 1.0.12 2.19.0 2.11.2 @@ -34,6 +34,7 @@ https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline + 1.1.4 local @@ -123,6 +124,13 @@ + + com.browserstack + browserstack-java-sdk + ${browserstack-java-sdk.version} + compile + + From ba22f397d6f0aff7af37218d99669069867b6b42 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Thu, 22 Dec 2022 20:30:43 +0100 Subject: [PATCH 039/191] new line added --- src/test/resources/suites/{parallel.xml => selenium-grid.xml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/test/resources/suites/{parallel.xml => selenium-grid.xml} (98%) diff --git a/src/test/resources/suites/parallel.xml b/src/test/resources/suites/selenium-grid.xml similarity index 98% rename from src/test/resources/suites/parallel.xml rename to src/test/resources/suites/selenium-grid.xml index cb1bd32..04d9024 100644 --- a/src/test/resources/suites/parallel.xml +++ b/src/test/resources/suites/selenium-grid.xml @@ -15,4 +15,4 @@ - \ No newline at end of file + From 43194e69507b1f0db229fc3a9fc9c0d03f35b0b6 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Thu, 22 Dec 2022 20:32:02 +0100 Subject: [PATCH 040/191] new target enum --- .../eliasnogueira/data/changeless/Target.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/main/java/com/eliasnogueira/data/changeless/Target.java diff --git a/src/main/java/com/eliasnogueira/data/changeless/Target.java b/src/main/java/com/eliasnogueira/data/changeless/Target.java new file mode 100644 index 0000000..52fc502 --- /dev/null +++ b/src/main/java/com/eliasnogueira/data/changeless/Target.java @@ -0,0 +1,55 @@ +/* + * MIT License + * + * Copyright (c) 2022 Elias Nogueira + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.eliasnogueira.data.changeless; + +import java.util.Collections; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public enum Target { + + LOCAL("local"), + SELENIUM_GRID("selenium-grid"), + BROWSERSTACK("browserstack"); + + private final String value; + private static final Map ENUM_MAP; + + Target(String value) { + this.value = value; + } + + static { + Map map = new ConcurrentHashMap<>(); + for (Target instance : Target.values()) { + map.put(instance.value.toLowerCase(), instance); + } + ENUM_MAP = Collections.unmodifiableMap(map); + } + + public static Target get(String value) { + return ENUM_MAP.get(value.toLowerCase()); + } +} From 5ed51e2bd014477aa37d50df58af69ff3d4de43b Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Thu, 22 Dec 2022 20:32:22 +0100 Subject: [PATCH 041/191] added new execution type: browserstack --- .../java/com/eliasnogueira/driver/TargetFactory.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/eliasnogueira/driver/TargetFactory.java b/src/main/java/com/eliasnogueira/driver/TargetFactory.java index 65d436b..0879bb7 100644 --- a/src/main/java/com/eliasnogueira/driver/TargetFactory.java +++ b/src/main/java/com/eliasnogueira/driver/TargetFactory.java @@ -24,6 +24,7 @@ package com.eliasnogueira.driver; +import com.eliasnogueira.data.changeless.Target; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.openqa.selenium.MutableCapabilities; @@ -39,11 +40,12 @@ public class TargetFactory { private static final Logger logger = LogManager.getLogger(TargetFactory.class); public WebDriver createInstance(String browser) { - Target target = Target.valueOf(configuration().target().toUpperCase()); + Target target = Target.get(configuration().target().toUpperCase()); return switch (target) { - case LOCAL -> BrowserFactory.valueOf(browser.toUpperCase()).createDriver(); - case REMOTE -> createRemoteInstance(BrowserFactory.valueOf(browser.toUpperCase()).getOptions()); + case LOCAL -> BrowserFactory.valueOf(browser.toUpperCase()).createLocalDriver(); + case BROWSERSTACK -> BrowserFactory.valueOf(browser.toUpperCase()).createDriver(); + case SELENIUM_GRID -> createRemoteInstance(BrowserFactory.valueOf(browser.toUpperCase()).getOptions()); }; } @@ -62,8 +64,4 @@ private RemoteWebDriver createRemoteInstance(MutableCapabilities capability) { return remoteWebDriver; } - - enum Target { - LOCAL, REMOTE - } } From 54ea4af18e6033afaab9c4c9172d377cdd093709 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Sun, 25 Dec 2022 16:41:06 +0100 Subject: [PATCH 042/191] making class not inheritable --- .../java/com/eliasnogueira/data/dynamic/BookingDataFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java b/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java index 28e1cde..f692852 100644 --- a/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java +++ b/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java @@ -35,7 +35,7 @@ import static com.eliasnogueira.config.ConfigurationManager.configuration; -public class BookingDataFactory { +public final class BookingDataFactory { private static final Faker faker = new Faker(new Locale(configuration().faker())); private static final Logger logger = LogManager.getLogger(BookingDataFactory.class); From 759d6f152ca51fb3f139764702f2a63f66d3cc0b Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Sun, 25 Dec 2022 16:41:11 +0100 Subject: [PATCH 043/191] making class not inheritable --- .../java/com/eliasnogueira/data/changeless/BrowserData.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eliasnogueira/data/changeless/BrowserData.java b/src/main/java/com/eliasnogueira/data/changeless/BrowserData.java index 48117a5..e600752 100644 --- a/src/main/java/com/eliasnogueira/data/changeless/BrowserData.java +++ b/src/main/java/com/eliasnogueira/data/changeless/BrowserData.java @@ -24,7 +24,7 @@ package com.eliasnogueira.data.changeless; -public class BrowserData { +public final class BrowserData { private BrowserData() { } From c61ff69d4c8d36e595f383cc847ec9f1f8ec2cc2 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Sun, 25 Dec 2022 16:41:25 +0100 Subject: [PATCH 044/191] new browserstack file --- browserstack.yml | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/browserstack.yml b/browserstack.yml index c582219..d43a8ac 100644 --- a/browserstack.yml +++ b/browserstack.yml @@ -1,25 +1,26 @@ # Set BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY as env variables # instead of adding it here -userName: YOUR_USERNAME -accessKey: YOUR_ACCESS_KEY -buildName: browserstack-build-1 -projectName: BrowserStack Samples +#userName: USER +#accessKey: ACCESS_KEY +buildName: book-a-room-test-1 +projectName: Selenium Java Lean Test Architecture framework: testng platforms: - - os: OS X - osVersion: Big Sur + - os: Windows + osVersion: 11 browserName: Chrome - browserVersion: latest + browserVersion: 103.0 - os: Windows osVersion: 10 - browserName: Edge - browserVersion: latest - - device: Samsung Galaxy S22 Ultra - browserName: chrome - osVersion: 12.0 + browserName: Firefox + browserVersion: 102.0 + - os: OS X + osVersion: Big Sur + browserName: Safari + browserVersion: 14.1 parallelsPerPlatform: 1 -source: testng:sample-master:v1.1 +source: selenium-lean-java-architecture browserstackLocal: true debug: false networkLogs: false From b2e0f25c215631b71032fe619e6df996d582f948 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Sun, 25 Dec 2022 16:41:51 +0100 Subject: [PATCH 045/191] libraries update --- pom.xml | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index a5cce9d..7934cee 100644 --- a/pom.xml +++ b/pom.xml @@ -28,13 +28,13 @@ 2.19.0 5.3.1 1.0.12 - 2.19.0 + 2.20.1 2.11.2 1.0.0 https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline - 1.1.4 + 1.1.5 local @@ -129,6 +129,12 @@ browserstack-java-sdk ${browserstack-java-sdk.version} compile + + + org.seleniumhq.selenium + selenium-java + + @@ -152,6 +158,37 @@ + + + browserstack + + + + maven-dependency-plugin + + + getClasspathFilenames + + properties + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + src/test/resources/suites/browserstack.xml + + + -javaagent:${com.browserstack:browserstack-java-sdk:jar} + + + + + + From 4b9c5d0397c54b26d02d55e50520e7c5012fbade Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Sun, 25 Dec 2022 16:42:01 +0100 Subject: [PATCH 046/191] moved target enum --- .../{data/changeless => enums}/Target.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) rename src/main/java/com/eliasnogueira/{data/changeless => enums}/Target.java (80%) diff --git a/src/main/java/com/eliasnogueira/data/changeless/Target.java b/src/main/java/com/eliasnogueira/enums/Target.java similarity index 80% rename from src/main/java/com/eliasnogueira/data/changeless/Target.java rename to src/main/java/com/eliasnogueira/enums/Target.java index 52fc502..ab34182 100644 --- a/src/main/java/com/eliasnogueira/data/changeless/Target.java +++ b/src/main/java/com/eliasnogueira/enums/Target.java @@ -22,17 +22,18 @@ * SOFTWARE. */ -package com.eliasnogueira.data.changeless; +package com.eliasnogueira.enums; import java.util.Collections; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import static java.util.Arrays.stream; +import static java.util.stream.Collectors.toMap; + public enum Target { - LOCAL("local"), - SELENIUM_GRID("selenium-grid"), - BROWSERSTACK("browserstack"); + LOCAL("local"), SELENIUM_GRID("selenium-grid"), BROWSERSTACK("browserstack"); private final String value; private static final Map ENUM_MAP; @@ -42,10 +43,8 @@ public enum Target { } static { - Map map = new ConcurrentHashMap<>(); - for (Target instance : Target.values()) { - map.put(instance.value.toLowerCase(), instance); - } + Map map = stream(Target.values()).collect(toMap( + instance -> instance.value.toLowerCase(), instance -> instance, (a, b) -> b, ConcurrentHashMap::new)); ENUM_MAP = Collections.unmodifiableMap(map); } From 16ee59ca3ef402a39cfea83d9940b60359d67b25 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Sun, 25 Dec 2022 16:42:19 +0100 Subject: [PATCH 047/191] refactoring after move target enum --- src/main/java/com/eliasnogueira/driver/TargetFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eliasnogueira/driver/TargetFactory.java b/src/main/java/com/eliasnogueira/driver/TargetFactory.java index 0879bb7..00bd16c 100644 --- a/src/main/java/com/eliasnogueira/driver/TargetFactory.java +++ b/src/main/java/com/eliasnogueira/driver/TargetFactory.java @@ -24,7 +24,7 @@ package com.eliasnogueira.driver; -import com.eliasnogueira.data.changeless.Target; +import com.eliasnogueira.enums.Target; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.openqa.selenium.MutableCapabilities; From f1db4787b500d13d30e9639bb7b1c4799d9142b1 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Sun, 25 Dec 2022 16:42:36 +0100 Subject: [PATCH 048/191] added browserstack run --- .github/workflows/test-execution.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index 29d5f84..044669e 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -28,5 +28,11 @@ jobs: restore-keys: ${{ runner.os }}-m2 - name: Build with Maven run: mvn -DskipTests -B package --file pom.xml - - name: Run tests - run: mvn test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome -Dtestng.dtd.http=true \ No newline at end of file + - name: Run local tests + run: mvn test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome + - uses: browserstack/github-actions/setup-env@master + - name: Run browserstack tests + run: mvn test -Pbrowserstack -Dtarget=browserstack + with: + username: ${{ secrets.BROWSERSTACK_USERNAME }} + access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} \ No newline at end of file From a13aeedc229b136fee3b4492c0c44a089b8e6e0a Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Sun, 25 Dec 2022 16:45:14 +0100 Subject: [PATCH 049/191] changed step --- .github/workflows/test-execution.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index 044669e..4a47b9a 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -32,7 +32,7 @@ jobs: run: mvn test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome - uses: browserstack/github-actions/setup-env@master - name: Run browserstack tests - run: mvn test -Pbrowserstack -Dtarget=browserstack with: username: ${{ secrets.BROWSERSTACK_USERNAME }} - access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} \ No newline at end of file + access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} + run: mvn test -Pbrowserstack -Dtarget=browserstack From 83a5a3bc1f38700bf797b04142361a7ef1aa839b Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Sun, 25 Dec 2022 16:46:56 +0100 Subject: [PATCH 050/191] adjustments in the browserstack run --- .github/workflows/test-execution.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index 4a47b9a..4bb83bb 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -20,19 +20,24 @@ jobs: with: java-version: 17 distribution: adopt + - name: Cache Maven packages uses: actions/cache@v3 with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 + - name: Build with Maven run: mvn -DskipTests -B package --file pom.xml + - name: Run local tests run: mvn test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome + - uses: browserstack/github-actions/setup-env@master - - name: Run browserstack tests + - name: Set browserstack credentials with: username: ${{ secrets.BROWSERSTACK_USERNAME }} access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} + - name: Run browserstack tests run: mvn test -Pbrowserstack -Dtarget=browserstack From 6224fb7227423abe237a3c6cab71816e337f98f9 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Sun, 25 Dec 2022 16:48:18 +0100 Subject: [PATCH 051/191] adjustments in the browserstack run --- .github/workflows/test-execution.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index 4bb83bb..620f362 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -34,8 +34,8 @@ jobs: - name: Run local tests run: mvn test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome - - uses: browserstack/github-actions/setup-env@master - name: Set browserstack credentials + - uses: browserstack/github-actions/setup-env@master with: username: ${{ secrets.BROWSERSTACK_USERNAME }} access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} From fda6eec5edf274147e59e06fb21261c1aa639d1c Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Sun, 25 Dec 2022 16:52:32 +0100 Subject: [PATCH 052/191] adjustments in the browserstack run --- .github/workflows/test-execution.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index 620f362..1474754 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -34,10 +34,5 @@ jobs: - name: Run local tests run: mvn test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome - - name: Set browserstack credentials - - uses: browserstack/github-actions/setup-env@master - with: - username: ${{ secrets.BROWSERSTACK_USERNAME }} - access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} - name: Run browserstack tests - run: mvn test -Pbrowserstack -Dtarget=browserstack + run: mvn test -Pbrowserstack -Dtarget=browserstack -DBROWSERSTACK_USERNAME=${{ secrets.BROWSERSTACK_USERNAME }} -DBROWSERSTACK_ACCESS_KEY=${{ secrets.BROWSERSTACK_ACCESS_KEY }} From 1ff141afa3cf1d04e6a7ca18d5ef0469dac743a7 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Mon, 26 Dec 2022 20:02:39 +0100 Subject: [PATCH 053/191] update ci/cd files --- pipeline_as_code/.gitlab-ci.yml | 2 +- pipeline_as_code/Jenkinsfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pipeline_as_code/.gitlab-ci.yml b/pipeline_as_code/.gitlab-ci.yml index 2cf2579..bf76065 100644 --- a/pipeline_as_code/.gitlab-ci.yml +++ b/pipeline_as_code/.gitlab-ci.yml @@ -17,4 +17,4 @@ build: test: stage: test script: - - mvn test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome -Dtestng.dtd.http=true \ No newline at end of file + - mvn test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome diff --git a/pipeline_as_code/Jenkinsfile b/pipeline_as_code/Jenkinsfile index f116189..21899b8 100644 --- a/pipeline_as_code/Jenkinsfile +++ b/pipeline_as_code/Jenkinsfile @@ -12,7 +12,7 @@ node { stage('Test Execution') { try { - sh "'${mvnHome}/bin/mvn' test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome -Dtestng.dtd.http=true" + sh "'${mvnHome}/bin/mvn' test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome } catch (Exception e) { currentBuild.result = 'FAILURE' } finally { From 38aa5acdd38d72b5e4d8c0be4b382ef534471cec Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Mon, 26 Dec 2022 20:03:03 +0100 Subject: [PATCH 054/191] removal of selenium exclusion on browserstack sdk --- pom.xml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 7934cee..d3882a4 100644 --- a/pom.xml +++ b/pom.xml @@ -129,12 +129,6 @@ browserstack-java-sdk ${browserstack-java-sdk.version} compile - - - org.seleniumhq.selenium - selenium-java - - @@ -161,6 +155,9 @@ browserstack + + browserstack + From 467bbefeac27e2d15a0566d3c77344526d0d41be Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Mon, 26 Dec 2022 20:03:11 +0100 Subject: [PATCH 055/191] general update --- README.MD | 224 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 154 insertions(+), 70 deletions(-) diff --git a/README.MD b/README.MD index 6137f1c..8b3edf9 100644 --- a/README.MD +++ b/README.MD @@ -1,50 +1,47 @@ # Lean Test Automation Architecture using Java and Selenium WebDriver + [![Actions Status](https://github.com/eliasnogueira/selenium-java-lean-test-achitecture/workflows/Build%20and%20Test/badge.svg)](https://github.com/eliasnogueira/selenium-java-lean-test-achitecture/actions) -**This project delivers to you a complete lean test architecture for your web tests using the best frameworks and practices.** +**This project delivers to you a complete lean test architecture for your web tests using the best frameworks and +practices.** ## Important information ### Know issues + ```shell -This current version has excluded the guava library from WebDriverManager and Allure Environment Writter -due to a conflict with the guava version on Selenium 4 +This current version has excluded the guava library from WebDriverManager and Allure Environment Writer +due to a conflict with the guava version of Selenium 4 ``` -### Java versions - -The `main` branch uses Java 17. - -If you want to use Java 11, please take a look at `java-11` branch. - ## Examples ### Local testing execution example ![Local testing execution example](assets/example_filed_test_with_report.gif) -### Parallel testing execution example with Docker Selenium +### Parallel testing execution example with Selenium Grid -![Parallel testing execution example with Docker Selenium](assets/selenium-grid-execution.gif) +![Parallel testing execution example with Selenium Grid](assets/selenium-grid-execution.gif) ## Languages and Frameworks -This project using the following languages and frameworks: +This project uses the following languages and frameworks: -* [Java 11](https://openjdk.java.net/projects/jdk/11/) as the programming language +* [Java 17](https://openjdk.java.net/projects/jdk/17/) as the programming language * [TestNG](https://testng.org/doc/) as the UnitTest framework to support the test creation * [Selenium WebDriver](https://www.selenium.dev/) as the web browser automation framework using the Java binding * [AssertJ](https://joel-costigliola.github.io/assertj/) as the fluent assertion library * [Allure Report](https://docs.qameta.io/allure/) as the testing report strategy -* [JavaFaker](https://github.com/DiUS/java-faker) as the faker data generation strategy +* [DataFaker](https://www.datafaker.net/) as the faker data generation strategy * [Log4J2](https://logging.apache.org/log4j/2.x/) as the logging management strategy * [WebDriverManager](https://github.com/bonigarcia/webdrivermanager) as the Selenium binaries management * [Owner](http://owner.aeonbits.org/) to minimize the code to handle the properties file - ## Test architecture -We know that any automation project starting with a good test architecture. +We know that any automation project starts with a good test architecture. + This project can be your initial test architecture for a faster start. You will see the following items in this architecture: @@ -62,11 +59,13 @@ You will see the following items in this architecture: Do you have any other items to add to this test architecture? Please do a pull request or open an issue to discuss. ### Page Objects pattern -I will not explain the Page Object pattern because you can find a lot of good explanations and examples on the internet. + +I will not explain the Page Object pattern because you can find a lot of good explanations and examples on the internet. Instead, I will explain what exactly about page objects I'm using in this project. #### AbstractPageObject -This class has a protected constructor to remove the necessity to init the elements using the Page Factory. + +This class has a protected constructor to remove the necessity to init the elements using the Page Factory. Also, it sets the timeout from the `timeout` property value located on `general.properties` file. All the Page Object classes should extend the `AbstractPageObject`. @@ -77,87 +76,135 @@ It also tries to remove the `driver` object from the Page Object class as much a > There's a `NavigationPage` on the `common` package inside the Page Objects. > Notice that all the pages extend this one instead of the `AbstractPageObject`. I implemented this way: > * because the previous and next buttons are fixed on the page (there's no refresh on the page) -> * to avoid create or pass the new reference to the `NavigationPage` when we need to hit previous or next buttons +> * to avoid creating or passing the new reference to the `NavigationPage` when we need to hit previous or next buttons As much as possible avoid this strategy to not get an `ElementNotFoundException` or `StaleElementReferenceException`. Use this approach if you know that the page does not refresh. ### Execution types -There are two execution types: **local** and **remote**. -The `TargetFactory` class will resolve the target execution based on the `target` property value located on `general.properties` file. -Its usage is placed on the `BaseWeb` class before each test execution. +There are three execution types: + +- `local` +- `selenium-grid` +- `browserstack` + The `TargetFactory` class will resolve the target execution based on the `target` property value located + on `general.properties` file. + Its usage is placed on the `BaseWeb` class before each test execution. #### Local execution -This execution type uses [WebDriverManager](https://github.com/bonigarcia/webdrivermanager) class to instantiate the web browsers. -When the `target` is `local` the `createDriver()` method is used from the `BrowserFactory` class to return the browser instance. + +This execution type uses [WebDriverManager](https://github.com/bonigarcia/webdrivermanager) class to instantiate the web +browsers. +When the `target` is `local` the `createLocalDriver()` method is used from the `BrowserFactory` class to return the +browser instance. The browser used in the test is placed on the `browser` property in the `local.properties` file. #### Remote execution -This execution is based on any Selenium Grid approach to execute the tests in remote machines (local or remote/cloud grid). -When the `target` is `remote` the `getOptions` method is used from the `BrowserFactory` to return the browser option + +##### Selenium Grid + +The Selenium Grid approach executes the tests in remote machines (local or remote/cloud grid). +When the `target` is `selenium-grid` the `getOptions` method is used from the `BrowserFactory` to return the browser +option class as the remote execution needs the browser capability. -The `DriverFactory` class has an internal method `createRemoteInstance` to return a `RemoteWebDriver` instance based on + +The `DriverFactory` class has an internal method `createRemoteInstance` to return a `RemoteWebDriver` instance based on the browser capability. You must pay attention to the two required information regarding the remote execution: the `grid.url` and `grid.port` property values on the `grid.properties` file. You must update these values before the start. -If you are using the `docker-compose.yml` file to start the Docker Selenium grid, the values on the `grid.properties` file should work. +If you are using the `docker-compose.yml` file to start the Docker Selenium grid, the values on the `grid.properties` +file should work. + +You can take a look at the [Execution with Docker Selenium Distributed](#execution-with-docker-selenium-distributed) +to run the parallel tests using this example. + +##### Browserstack + +The Browserstack approach runs the tests in the browserstack cloud. -Please take a look at the [Parallel Execution](#parallel-execution) section. +When the `target` is `browserstack` the `createDriver` method is used from the `BrowserFactory` to return the browser(s) +set in the `src/test/resources/suites/browserstack.xml` test suite. + +You can take a look at the [Execution with Browserstack](#execution-with-browserstack) +to run the parallel tests using this example. #### BrowserFactory class + This Factory class is a Java enum that has all implemented browsers to use during the test execution. -Each browser is an enum, and each enum implements two methods: -* `createDriver()`: creates the browser instance for the local execution. The browser driver is automatically managed by the WebDriverManager library -* `getOptions()`: creates a new browser Options setting some specific configurations. It's used for the remote executions +Each browser is an `enum`, and each enum implements three methods: + +* `createLocalDriver()`: creates the browser instance for the local execution. The browser driver is automatically + managed by the WebDriverManager library +* `createDriver()`: creates the browser instance for the remote execution using the Browserstack cloud +* `getOptions()`: creates a new browser `Options` setting some specific configurations, and it's used for the remote + executions using the Selenium Grid -You can see that the `createDriver()` method used the `getOptions()` to use specific configuration, as starting the browser maximized and others. -The `getOptions()` is also used for the remote execution as it is a subclass of the `AbstractDriverOptions` and can be -automatically accepted as either a `Capabilities` or `MutableCapabilities` class, which is required by the `RemoteWebDriver` class. +You can see that the `createLocalDriver()` method use the `getOptions()` to get specific browser configurations, as +starting the browser maximized and others. + +The `getOptions()` is also used for the remote execution as it is a subclass of the `AbstractDriverOptions` and can be +automatically accepted as either a `Capabilities` or `MutableCapabilities` class, which is required by +the `RemoteWebDriver` class. #### DriverManager class -The class [DriverManager](https://github.com/eliasnogueira/selenium-java-lean-test-achitecture/blob/master/src/main/java/com/eliasnogueira/driver/DriverManager.java) + +The +class [DriverManager](https://github.com/eliasnogueira/selenium-java-lean-test-achitecture/blob/master/src/main/java/com/eliasnogueira/driver/DriverManager.java) create a `ThreadLocal` for the WebDriver instance, to make sure there's no conflict when we run it in parallel. ### BaseTest -This testing pattern was implemented on the [BaseWeb](https://github.com/eliasnogueira/selenium-java-lean-test-achitecture/blob/master/src/test/java/com/eliasnogueira/BaseWeb.java) + +This testing pattern was implemented on +the [BaseWeb](https://github.com/eliasnogueira/selenium-java-lean-test-achitecture/blob/master/src/test/java/com/eliasnogueira/BaseWeb.java) class to automatically run the pre (setup) and post (teardown) conditions. -The pre-condition uses `@BeforeMethod` from TestNG creates the browser instance based on the values passed either local or remote execution. +The pre-condition uses `@BeforeMethod` from TestNG creates the browser instance based on the values passed either local +or remote execution. The post-condition uses `@AfterMethod` to close the browser instance. Both have the `alwaysRun` parameter as `true` to force the run on a pipeline. -Pay attention that it was designed to open a browser instance to each `@Test` located on the test class. +Pay attention that it was designed to open a browser instance to each `@Test` located in the test class. -This class also the `TestListener` that is a custom TestNG listener, and will be described in the next section. +This class also has the `TestListener` annotation which is a custom TestNG listener, and will be described in the next +section. ### TestListener -The `TestListener` is a class that implements [ITestListener](https://testng.org/doc/documentation-main.html#logging-listeners). +The `TestListener` is a class that +implements [ITestListener](https://testng.org/doc/documentation-main.html#logging-listeners). The following method is used to help logging errors and attach additional information to the test report: -* `onTestStart`: add the browser information into the test report + +* `onTestStart`: add the browser information to the test report * `onTestFailure`: log the exceptions and add a screenshot to the test report -* `onTestSkipped`: add the skipped test on the log +* `onTestSkipped`: add the skipped test to the log ### Logging + All the log is done by the Log4J using the `@Log4j2` annotation. The `log4j2.properties` has two strategies: console and file. -A file with all the log information will be automatically created on the user folder with `test_automation.log` filename. +A file with all the log information will be automatically created on the user folder with `test_automation.log` +filename. If you want to change it, update the `appender.file.fileName` property value. -The `log.error` is used to log all the exceptions this architecture might throw. Use `log.info` or `log.debug` to log -important information, like the users, automatically generated by the factory [BookingDataFactory](https://github.com/eliasnogueira/selenium-java-lean-test-achitecture/blob/master/src/main/java/com/eliasnogueira/data/BookingDataFactory.java) +The `log.error` is used to log all the exceptions this architecture might throw. Use `log.info` or `log.debug` to log +important information, like the users, automatically generated by the +factory [BookingDataFactory](https://github.com/eliasnogueira/selenium-java-lean-test-achitecture/blob/master/src/main/java/com/eliasnogueira/data/BookingDataFactory.java) ### Parallel execution -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 `parallel.xml` test suite file which has the `parallel="tests"` attribute and value, + +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 `parallel.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: + ```xml + ``` @@ -166,53 +213,87 @@ You can define any parallel strategy. It can be an excellent combination together with the grid strategy. #### Execution with Docker Selenium Distributed + This project has the `docker-compose.yml` file to run the tests in a parallel way using Docker Selenium. -To be able to run it in parallel the file has the [Dynamic Grid Implementation](https://github.com/SeleniumHQ/docker-selenium#dynamic-grid-) that will start the container on demand. +To be able to run it in parallel the file has +the [Dynamic Grid Implementation](https://github.com/SeleniumHQ/docker-selenium#dynamic-grid-) that will start the +container on demand. This means that Docker Selenium will start a container test for a targeting browser. -Please not you need the following before run it in parallel: +Please note that you need to do the following actions before running it in parallel: + * Docker installed * Pull the images for Chrome and Firefox - * `docker pull selenium-standalog-chrome` - * `docker pull selenium-standalog-firefox` -* Pay attention at the `grid/config.toml` file that has comments for each specific SO -* Start the Grid running the following command inside the `grid` folder - * `docker-compose up` + * `docker pull selenium-standalog-chrome` + * `docker pull selenium-standalog-firefox` +* 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` + +#### Execution with Browserstack + +This project uses +the [Browserstack SDK](https://www.browserstack.com/docs/automate/selenium/browserstack-sdk/core-concepts) +to run the tests in the Browserstack cloud using the `browserstack.yml` file in the project root directory. + +You need a username and access key to run the tests and, For education purposes, you can set it in +the `browserstack.yml` file, but the recommended way is to set it as an environment variable in your local machine. + +To run the test in the Browserstack cloud, you need to: + +* set the username and access key in the `browserstack.yml` file + or [create the related environment variables](https://automate.browserstack.com/dashboard/v2/quick-start/setup-browserstack-sdk) +* run the tests using the following command: `mvn test -Pbrowserstack` + +The tests will only run using the `browserstack` profile because the Browserstack SDK is configured as a Java Agent, so +it's there only +for these tests. It's also worth to mention that the profile automatically sets the `target` property to `browserstack`. ### Configuration files -This project uses a library called [Owner](http://owner.aeonbits.org/). You can find the class related to the property + +This project uses a library called [Owner](http://owner.aeonbits.org/). You can find the class related to the property file reader in the following classes: + * [Configuration](https://github.com/eliasnogueira/selenium-java-lean-test-achitecture/blob/master/src/main/java/com/eliasnogueira/config/Configuration.java) * [ConfigurationManager](https://github.com/eliasnogueira/selenium-java-lean-test-achitecture/blob/master/src/main/java/com/eliasnogueira/config/ConfigurationManager.java) There are 3 properties (configuration) files located on `src/test/java/resources/`: + * `general.properties`: general configuration as the target execution, base url, timeout, and faker locale * `grid.properties`: url and port for the Selenium grid usage * `local.properties`: browser to use in the local execution -The properties were divided into three different ones to better separate the responsibilities and enable the changes easy -without have a lot of properties inside a single file. +The properties were divided into three different ones to better separate the responsibilities and enable the changes +easy without having a lot of properties inside a single file. ### Test Data Factory + Is the utilization of the Factory design pattern with the Fluent Builder to generate dynamic data. -The [BookingDataFactory](https://github.com/eliasnogueira/selenium-java-lean-test-achitecture/blob/master/src/main/java/com/eliasnogueira/data/BookingDataFactory.java) +The [BookingDataFactory](https://github.com/eliasnogueira/selenium-java-lean-test-achitecture/blob/master/src/main/java/com/eliasnogueira/data/BookingDataFactory.java) has only one factory `createBookingData` returning a `Booking` object with dynamic data. This dynamic data is generated by JavaFaker filling all the fields using the Build pattern. -The [Booking](https://github.com/eliasnogueira/selenium-java-lean-test-achitecture/blob/master/src/main/java/com/eliasnogueira/model/Booking.java) is the plain Java objects -and the [BookingBuilder](https://github.com/eliasnogueira/selenium-java-lean-test-achitecture/blob/master/src/main/java/com/eliasnogueira/model/BookingBuilder.java) is the builder class. +The [Booking](https://github.com/eliasnogueira/selenium-java-lean-test-achitecture/blob/master/src/main/java/com/eliasnogueira/model/Booking.java) +is the plain Java objects +and +the [BookingBuilder](https://github.com/eliasnogueira/selenium-java-lean-test-achitecture/blob/master/src/main/java/com/eliasnogueira/model/BookingBuilder.java) +is the builder class. -You can ses the use of the Builder pattern in the [BookingDataFactory](https://github.com/eliasnogueira/selenium-java-lean-test-achitecture/blob/master/src/main/java/com/eliasnogueira/data/BookingDataFactory.java) class. +You can see the usage of the Builder pattern in +the [BookingDataFactory](https://github.com/eliasnogueira/selenium-java-lean-test-achitecture/blob/master/src/main/java/com/eliasnogueira/data/BookingDataFactory.java) +class. Reading reference: https://reflectoring.io/objectmother-fluent-builder ### Profiles executors on pom.xml -There is a profile called `web-execution` created to execute the test suite `local.xml` inside `src/test/resources/suites` folder. +There is a profile called `web-execution` created to execute the test suite `local.xml` +inside `src/test/resources/suites` folder. To execute this suite, via the command line you can call the parameter `-P` and the profile id. Eg: executing the multi_browser suite + ``` bash mvn test -Pweb-execution -Dtestng.dtd.http=true ``` @@ -223,26 +304,29 @@ To do this you need: * Create a property on `pom.xml` called _suite_ ```xml - - local - + + + local + ``` * Change the profile id ```xml + - web-execution + web-execution ``` * Replace the xml file name to `${suite}` on the profile ```xml + - - src/test/resources/suites/${suite}.xml - + + src/test/resources/suites/${suite}.xml + ``` From c89892155574e60c8c80ed78975bca460816770a Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Mon, 26 Dec 2022 21:50:40 +0100 Subject: [PATCH 056/191] added default methods for webdrivermanager setup --- .../java/com/eliasnogueira/driver/BrowserFactory.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java index 3b53e00..c3cd0f5 100644 --- a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java +++ b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java @@ -49,7 +49,7 @@ public enum BrowserFactory { CHROME { @Override public WebDriver createLocalDriver() { - WebDriverManager.getInstance(DriverManagerType.CHROME).setup(); + WebDriverManager.chromedriver().setup(); return new ChromeDriver(getOptions()); } @@ -72,7 +72,7 @@ public ChromeOptions getOptions() { }, FIREFOX { @Override public WebDriver createLocalDriver() { - WebDriverManager.getInstance(DriverManagerType.FIREFOX).setup(); + WebDriverManager.firefoxdriver().setup(); return new FirefoxDriver(getOptions()); } @@ -93,7 +93,7 @@ public FirefoxOptions getOptions() { }, EDGE { @Override public WebDriver createLocalDriver() { - WebDriverManager.getInstance(DriverManagerType.EDGE).setup(); + WebDriverManager.edgedriver().setup(); return new EdgeDriver(getOptions()); } @@ -114,7 +114,7 @@ public EdgeOptions getOptions() { }, SAFARI { @Override public WebDriver createLocalDriver() { - WebDriverManager.getInstance(DriverManagerType.SAFARI).setup(); + WebDriverManager.safaridriver().setup(); return new SafariDriver(getOptions()); } From fec13c12a36d6eec4f729951fe859dc83359a3a0 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Mon, 26 Dec 2022 21:57:56 +0100 Subject: [PATCH 057/191] exclusion of commons-io from browserstack-sdk --- pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pom.xml b/pom.xml index d3882a4..97b1fc8 100644 --- a/pom.xml +++ b/pom.xml @@ -129,6 +129,12 @@ browserstack-java-sdk ${browserstack-java-sdk.version} compile + + + commons-io + commons-io + + From b468ee8f6dfb1fff27b4144138a2bdff4889e82f Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Mon, 26 Dec 2022 22:04:18 +0100 Subject: [PATCH 058/191] exclusion of commons-io from browserstack-sdk --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index 97b1fc8..a98fd13 100644 --- a/pom.xml +++ b/pom.xml @@ -128,7 +128,6 @@ com.browserstack browserstack-java-sdk ${browserstack-java-sdk.version} - compile commons-io From 2c6d98bb7bc3dd3f6e3cdf08d8b75144c1b01a71 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Mon, 26 Dec 2022 22:04:30 +0100 Subject: [PATCH 059/191] removal of extra properties --- .github/workflows/test-execution.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index 1474754..893b0a6 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -35,4 +35,4 @@ jobs: run: mvn test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome - name: Run browserstack tests - run: mvn test -Pbrowserstack -Dtarget=browserstack -DBROWSERSTACK_USERNAME=${{ secrets.BROWSERSTACK_USERNAME }} -DBROWSERSTACK_ACCESS_KEY=${{ secrets.BROWSERSTACK_ACCESS_KEY }} + run: mvn test -Pbrowserstack -DBROWSERSTACK_USERNAME=${{ secrets.BROWSERSTACK_USERNAME }} -DBROWSERSTACK_ACCESS_KEY=${{ secrets.BROWSERSTACK_ACCESS_KEY }} From c59e87d59c8e62f26383d2f3805a25aabd8be98e Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Wed, 28 Dec 2022 18:20:38 +0100 Subject: [PATCH 060/191] added batch mode to maven execution --- .github/workflows/test-execution.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index 893b0a6..4f0c45b 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -32,7 +32,7 @@ jobs: run: mvn -DskipTests -B package --file pom.xml - name: Run local tests - run: mvn test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome + run: mvn -B test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome - name: Run browserstack tests - run: mvn test -Pbrowserstack -DBROWSERSTACK_USERNAME=${{ secrets.BROWSERSTACK_USERNAME }} -DBROWSERSTACK_ACCESS_KEY=${{ secrets.BROWSERSTACK_ACCESS_KEY }} + run: mvn -B test -Pbrowserstack -DBROWSERSTACK_USERNAME=${{ secrets.BROWSERSTACK_USERNAME }} -DBROWSERSTACK_ACCESS_KEY=${{ secrets.BROWSERSTACK_ACCESS_KEY }} From ed331dfe09342851caa1563046a9982159210c8e Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Wed, 28 Dec 2022 18:28:27 +0100 Subject: [PATCH 061/191] addeds target to browserstack execution --- .github/workflows/test-execution.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index 4f0c45b..f221e49 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -35,4 +35,4 @@ jobs: run: mvn -B test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome - name: Run browserstack tests - run: mvn -B test -Pbrowserstack -DBROWSERSTACK_USERNAME=${{ secrets.BROWSERSTACK_USERNAME }} -DBROWSERSTACK_ACCESS_KEY=${{ secrets.BROWSERSTACK_ACCESS_KEY }} + run: mvn -B test -Pbrowserstack -target=browserstack -DBROWSERSTACK_USERNAME=${{ secrets.BROWSERSTACK_USERNAME }} -DBROWSERSTACK_ACCESS_KEY=${{ secrets.BROWSERSTACK_ACCESS_KEY }} From 66ae480b83808c1ae38ca90218de44d3a84512b3 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Wed, 28 Dec 2022 18:28:46 +0100 Subject: [PATCH 062/191] addeds target to browserstack execution --- .github/workflows/test-execution.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index f221e49..27f58df 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -35,4 +35,4 @@ jobs: run: mvn -B test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome - name: Run browserstack tests - run: mvn -B test -Pbrowserstack -target=browserstack -DBROWSERSTACK_USERNAME=${{ secrets.BROWSERSTACK_USERNAME }} -DBROWSERSTACK_ACCESS_KEY=${{ secrets.BROWSERSTACK_ACCESS_KEY }} + run: mvn -B test -Pbrowserstack -Dtarget=browserstack -DBROWSERSTACK_USERNAME=${{ secrets.BROWSERSTACK_USERNAME }} -DBROWSERSTACK_ACCESS_KEY=${{ secrets.BROWSERSTACK_ACCESS_KEY }} From dded426b49eae0a2320fc5e8b50d1f2c03e92fab Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Wed, 28 Dec 2022 18:33:15 +0100 Subject: [PATCH 063/191] change chrome browserstack capability --- .github/workflows/test-execution.yml | 7 ++++--- src/main/java/com/eliasnogueira/driver/BrowserFactory.java | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index 27f58df..8d9f412 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -24,9 +24,10 @@ jobs: - name: Cache Maven packages uses: actions/cache@v3 with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- - name: Build with Maven run: mvn -DskipTests -B package --file pom.xml diff --git a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java index c3cd0f5..5b69f36 100644 --- a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java +++ b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java @@ -56,7 +56,7 @@ public WebDriver createLocalDriver() { @Override public WebDriver createDriver() { - return new ChromeDriver(getOptions()); + return new ChromeDriver(); } @Override From 2f035562a7a7a2caae6a2967cdf9bafffcc9ef47 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Wed, 28 Dec 2022 18:38:41 +0100 Subject: [PATCH 064/191] changing jobs --- .github/workflows/test-execution.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index 8d9f412..9de3cc9 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -28,12 +28,20 @@ jobs: key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-maven- - - name: Build with Maven - run: mvn -DskipTests -B package --file pom.xml + run: mvn -B -DskipTests package --file pom.xml + local_test: + runs-on: ubuntu-latest + services: + chrome: + image: selenium/standalone-chrome + options: --health-cmd '/opt/bin/check-grid.sh' + steps: - name: Run local tests run: mvn -B test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome + browserstack-test: + runs-on: ubuntu-latest - name: Run browserstack tests run: mvn -B test -Pbrowserstack -Dtarget=browserstack -DBROWSERSTACK_USERNAME=${{ secrets.BROWSERSTACK_USERNAME }} -DBROWSERSTACK_ACCESS_KEY=${{ secrets.BROWSERSTACK_ACCESS_KEY }} From 11d31cc3979b79a7ee1053cea8224ed03a595bcb Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Wed, 28 Dec 2022 18:39:24 +0100 Subject: [PATCH 065/191] changing jobs --- .github/workflows/test-execution.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index 9de3cc9..22dc5ae 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -43,5 +43,6 @@ jobs: browserstack-test: runs-on: ubuntu-latest + steps: - name: Run browserstack tests run: mvn -B test -Pbrowserstack -Dtarget=browserstack -DBROWSERSTACK_USERNAME=${{ secrets.BROWSERSTACK_USERNAME }} -DBROWSERSTACK_ACCESS_KEY=${{ secrets.BROWSERSTACK_ACCESS_KEY }} From 369c38e60fa2e99a1d07eb159d6f8df1f6a62532 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Wed, 28 Dec 2022 18:51:17 +0100 Subject: [PATCH 066/191] split actions --- .github/workflows/test-execution.yml | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index 22dc5ae..6425506 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -7,7 +7,7 @@ on: branches: - main jobs: - build: + local_test: runs-on: ubuntu-latest services: chrome: @@ -30,19 +30,26 @@ jobs: ${{ runner.os }}-maven- - name: Build with Maven run: mvn -B -DskipTests package --file pom.xml - - local_test: - runs-on: ubuntu-latest - services: - chrome: - image: selenium/standalone-chrome - options: --health-cmd '/opt/bin/check-grid.sh' - steps: - name: Run local tests run: mvn -B test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome browserstack-test: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v3 + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: adopt + + - name: Cache Maven packages + uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Run browserstack tests run: mvn -B test -Pbrowserstack -Dtarget=browserstack -DBROWSERSTACK_USERNAME=${{ secrets.BROWSERSTACK_USERNAME }} -DBROWSERSTACK_ACCESS_KEY=${{ secrets.BROWSERSTACK_ACCESS_KEY }} From 7a84bd1ed7d06f575066ca93cfa02b4c00af673f Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Wed, 28 Dec 2022 18:59:57 +0100 Subject: [PATCH 067/191] added browserstack related actions --- .github/workflows/test-execution.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index 6425506..fa14256 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -7,7 +7,7 @@ on: branches: - main jobs: - local_test: + local-test: runs-on: ubuntu-latest services: chrome: @@ -51,5 +51,22 @@ jobs: restore-keys: | ${{ runner.os }}-maven- + - name: BrowserStack Env Setup + uses: browserstack/github-actions/setup-env@master + with: + username: ${{ secrets.BROWSERSTACK_USERNAME }} + access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} + project-name: selenium-lean-java-architecture + + - name: Start BrowserStackLocal Tunnel + uses: browserstack/github-actions/setup-local@master + with: + local-testing: start + - name: Run browserstack tests run: mvn -B test -Pbrowserstack -Dtarget=browserstack -DBROWSERSTACK_USERNAME=${{ secrets.BROWSERSTACK_USERNAME }} -DBROWSERSTACK_ACCESS_KEY=${{ secrets.BROWSERSTACK_ACCESS_KEY }} + + - name: Start BrowserStackLocal Tunnel + uses: browserstack/github-actions/setup-local@master + with: + local-testing: stop \ No newline at end of file From a3190b949b0ca6a3dae424b0c7b486c07e55cfd7 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Wed, 28 Dec 2022 19:03:26 +0100 Subject: [PATCH 068/191] removal of explicit secrets --- .github/workflows/test-execution.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index fa14256..7ed31c1 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -64,7 +64,7 @@ jobs: local-testing: start - name: Run browserstack tests - run: mvn -B test -Pbrowserstack -Dtarget=browserstack -DBROWSERSTACK_USERNAME=${{ secrets.BROWSERSTACK_USERNAME }} -DBROWSERSTACK_ACCESS_KEY=${{ secrets.BROWSERSTACK_ACCESS_KEY }} + run: mvn -B test -Pbrowserstack - name: Start BrowserStackLocal Tunnel uses: browserstack/github-actions/setup-local@master From 4737355faaf8eeb3e2bff8e8b4eee95a2d4a44e1 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Fri, 30 Dec 2022 12:47:56 +0100 Subject: [PATCH 069/191] added check for adding the grid information --- .../eliasnogueira/report/AllureManager.java | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/eliasnogueira/report/AllureManager.java b/src/main/java/com/eliasnogueira/report/AllureManager.java index 8dd5891..24e844a 100644 --- a/src/main/java/com/eliasnogueira/report/AllureManager.java +++ b/src/main/java/com/eliasnogueira/report/AllureManager.java @@ -25,11 +25,14 @@ package com.eliasnogueira.report; import com.eliasnogueira.driver.DriverManager; +import com.eliasnogueira.enums.Target; import com.github.automatedowl.tools.AllureEnvironmentWriter; import com.google.common.collect.ImmutableMap; import io.qameta.allure.Attachment; import org.openqa.selenium.TakesScreenshot; +import java.util.Map; + import static com.eliasnogueira.config.ConfigurationManager.configuration; import static org.openqa.selenium.OutputType.BYTES; @@ -39,17 +42,21 @@ private AllureManager() { } public static void setAllureEnvironmentInformation() { - AllureEnvironmentWriter.allureEnvironmentWriter( - ImmutableMap.builder(). - put("Test URL", configuration().url()). - put("Target execution", configuration().target()). - put("Global timeout", String.valueOf(configuration().timeout())). - put("Headless mode", String.valueOf(configuration().headless())). - put("Faker locale", configuration().faker()). - put("Local browser", configuration().browser()). - put("Grid URL", configuration().gridUrl()). - put("Grid port", configuration().gridPort()). - build()); + var basicInfo = Map.of( + "Test URL", configuration().url(), + "Target execution", configuration().target(), + "Global timeout", String.valueOf(configuration().timeout()), + "Headless mode", String.valueOf(configuration().headless()), + "Faker locale", configuration().faker(), + "Local browser", configuration().browser() + ); + + if (configuration().target().equals(Target.SELENIUM_GRID)) { + var gridMap = Map.of("Grid URL", configuration().gridUrl(), "Grid port", configuration().gridPort()); + basicInfo.putAll(gridMap); + } + + AllureEnvironmentWriter.allureEnvironmentWriter(ImmutableMap.copyOf(basicInfo)); } @Attachment(value = "Failed test screenshot", type = "image/png") @@ -61,5 +68,4 @@ public static byte[] takeScreenshotToAttachOnAllureReport() { public static String addBrowserInformationOnAllureReport() { return DriverManager.getInfo(); } - } From 0536cc909cc7f0e141aeb7511d21a0dfa7279dac Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Fri, 30 Dec 2022 12:48:04 +0100 Subject: [PATCH 070/191] reusable action --- .github/workflows/checkout-cache-build.yaml | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/checkout-cache-build.yaml diff --git a/.github/workflows/checkout-cache-build.yaml b/.github/workflows/checkout-cache-build.yaml new file mode 100644 index 0000000..8aa7709 --- /dev/null +++ b/.github/workflows/checkout-cache-build.yaml @@ -0,0 +1,24 @@ +name: Reusable checkout and cache + +jobs: + local-test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: adopt + + - name: Cache Maven packages + uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Build with Maven + run: mvn -B -DskipTests package --file pom.xml From 49d6045c7f92bcfaff5041d5eaea010bbe253d32 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Fri, 30 Dec 2022 12:48:22 +0100 Subject: [PATCH 071/191] merge local.properties to general.properties --- src/test/resources/general.properties | 7 +++++-- src/test/resources/local.properties | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) delete mode 100644 src/test/resources/local.properties diff --git a/src/test/resources/general.properties b/src/test/resources/general.properties index 3b7c736..86a5fad 100644 --- a/src/test/resources/general.properties +++ b/src/test/resources/general.properties @@ -1,5 +1,8 @@ -# target execution: local, selenium-grid or browserstack -target = local +# target execution: local, selenium-grid, browserstack or testcontainers +target = testcontainers + +# browser to use for local and testcontainers execution +browser = chrome # initial URL url.base = http://eliasnogueira.com/external/selenium-java-architecture/ diff --git a/src/test/resources/local.properties b/src/test/resources/local.properties deleted file mode 100644 index 193bc16..0000000 --- a/src/test/resources/local.properties +++ /dev/null @@ -1 +0,0 @@ -browser = chrome From 5f9a172674daad440be7863845bbfad2703d53a4 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Fri, 30 Dec 2022 12:48:53 +0100 Subject: [PATCH 072/191] added testcontainers dependency --- pom.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a98fd13..f726796 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.1.0 + 3.2.0 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -35,6 +35,7 @@ https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline 1.1.5 + 1.17.6 local @@ -136,6 +137,12 @@ + + org.testcontainers + selenium + ${testcontainers.selenium.version} + + From f5402aaabcb9da81e0c8105fd98fd43980419569 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Fri, 30 Dec 2022 12:49:00 +0100 Subject: [PATCH 073/191] added testcontainers --- README.MD | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.MD b/README.MD index 8b3edf9..da24106 100644 --- a/README.MD +++ b/README.MD @@ -88,9 +88,10 @@ There are three execution types: - `local` - `selenium-grid` - `browserstack` - The `TargetFactory` class will resolve the target execution based on the `target` property value located - on `general.properties` file. - Its usage is placed on the `BaseWeb` class before each test execution. +- `testcontainers` + +The `TargetFactory` class will resolve the target execution based on the `target` property value located +on `general.properties` file. Its usage is placed on the `BaseWeb` class before each test execution. #### Local execution @@ -99,7 +100,7 @@ browsers. When the `target` is `local` the `createLocalDriver()` method is used from the `BrowserFactory` class to return the browser instance. -The browser used in the test is placed on the `browser` property in the `local.properties` file. +The browser used in the test is placed on the `browser` property in the `general.properties` file. #### Remote execution @@ -260,9 +261,8 @@ file reader in the following classes: There are 3 properties (configuration) files located on `src/test/java/resources/`: -* `general.properties`: general configuration as the target execution, base url, timeout, and faker locale +* `general.properties`: general configuration as the target execution, browser, base url, timeout, and faker locale * `grid.properties`: url and port for the Selenium grid usage -* `local.properties`: browser to use in the local execution The properties were divided into three different ones to better separate the responsibilities and enable the changes easy without having a lot of properties inside a single file. From 6f55ac8db177655ae7f1ff3da439ac6129ba6e90 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Fri, 30 Dec 2022 12:49:21 +0100 Subject: [PATCH 074/191] added testcontainers --- .../eliasnogueira/driver/TargetFactory.java | 33 +++++++++++++++---- .../java/com/eliasnogueira/enums/Target.java | 3 +- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/eliasnogueira/driver/TargetFactory.java b/src/main/java/com/eliasnogueira/driver/TargetFactory.java index 00bd16c..1fc84cd 100644 --- a/src/main/java/com/eliasnogueira/driver/TargetFactory.java +++ b/src/main/java/com/eliasnogueira/driver/TargetFactory.java @@ -30,10 +30,14 @@ import org.openqa.selenium.MutableCapabilities; import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.RemoteWebDriver; +import org.testcontainers.containers.BrowserWebDriverContainer; import java.net.URL; import static com.eliasnogueira.config.ConfigurationManager.configuration; +import static com.eliasnogueira.driver.BrowserFactory.*; +import static java.lang.String.format; +import static org.apache.commons.lang3.ObjectUtils.notEqual; public class TargetFactory { @@ -43,25 +47,42 @@ public WebDriver createInstance(String browser) { Target target = Target.get(configuration().target().toUpperCase()); return switch (target) { - case LOCAL -> BrowserFactory.valueOf(browser.toUpperCase()).createLocalDriver(); - case BROWSERSTACK -> BrowserFactory.valueOf(browser.toUpperCase()).createDriver(); - case SELENIUM_GRID -> createRemoteInstance(BrowserFactory.valueOf(browser.toUpperCase()).getOptions()); + case LOCAL -> valueOf(configuration().browser().toUpperCase()).createLocalDriver(); + case BROWSERSTACK -> valueOf(browser.toUpperCase()).createDriver(); + case SELENIUM_GRID -> createRemoteInstance(valueOf(browser.toUpperCase()).getOptions()); + case TESTCONTAINERS -> + createTestContainersInstance(valueOf(configuration().browser().toUpperCase()).getOptions()); }; } private RemoteWebDriver createRemoteInstance(MutableCapabilities capability) { RemoteWebDriver remoteWebDriver = null; try { - String gridURL = String.format("http://%s:%s", configuration().gridUrl(), configuration().gridPort()); + String gridURL = format("http://%s:%s", configuration().gridUrl(), configuration().gridPort()); remoteWebDriver = new RemoteWebDriver(new URL(gridURL), capability); } catch (java.net.MalformedURLException e) { logger.error("Grid URL is invalid or Grid is not available"); - logger.error(String.format("Browser: %s", capability.getBrowserName()), e); + logger.error(format("Browser: %s", capability.getBrowserName()), e); } catch (IllegalArgumentException e) { - logger.error(String.format("Browser %s is not valid or recognized", capability.getBrowserName()), e); + logger.error(format("Browser %s is not valid or recognized", capability.getBrowserName()), e); } return remoteWebDriver; } + + private RemoteWebDriver createTestContainersInstance(MutableCapabilities capabilities) { + String browser = capabilities.getBrowserName(); + + if (notEqual(browser, CHROME.toString().toLowerCase()) && notEqual(browser, CHROME.toString().toLowerCase())) { + throw new IllegalArgumentException( + format("Browser %s not supported for TestContainers", capabilities.getBrowserName())); + } + + try (BrowserWebDriverContainer driverContainer = new BrowserWebDriverContainer<>().withCapabilities(capabilities)) { + driverContainer.start(); + + return new RemoteWebDriver(driverContainer.getSeleniumAddress(), capabilities); + } + } } diff --git a/src/main/java/com/eliasnogueira/enums/Target.java b/src/main/java/com/eliasnogueira/enums/Target.java index ab34182..ad14f52 100644 --- a/src/main/java/com/eliasnogueira/enums/Target.java +++ b/src/main/java/com/eliasnogueira/enums/Target.java @@ -33,7 +33,8 @@ public enum Target { - LOCAL("local"), SELENIUM_GRID("selenium-grid"), BROWSERSTACK("browserstack"); + LOCAL("local"), SELENIUM_GRID("selenium-grid"), BROWSERSTACK("browserstack"), + TESTCONTAINERS("testcontainers"); private final String value; private static final Map ENUM_MAP; From 3581db7db1d38a66f5c47813cb849a9d6033f701 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Fri, 30 Dec 2022 12:49:36 +0100 Subject: [PATCH 075/191] using reusable workflow --- .github/workflows/test-execution.yml | 40 +++++++--------------------- 1 file changed, 9 insertions(+), 31 deletions(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index 7ed31c1..85e3c54 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -13,44 +13,22 @@ jobs: chrome: image: selenium/standalone-chrome options: --health-cmd '/opt/bin/check-grid.sh' + uses: /.github/workflows/checkout-cache-build.yaml steps: - - uses: actions/checkout@v3 - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: 17 - distribution: adopt - - - name: Cache Maven packages - uses: actions/cache@v3 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - name: Build with Maven - run: mvn -B -DskipTests package --file pom.xml - name: Run local tests run: mvn -B test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome - browserstack-test: + testcontainers-test: runs-on: ubuntu-latest + uses: /.github/workflows/checkout-cache-build.yaml steps: - - uses: actions/checkout@v3 - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: 17 - distribution: adopt - - - name: Cache Maven packages - uses: actions/cache@v3 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- + - name: Run local tests + run: mvn -B test -Dtarget=testcontainers -Dbrowser=chrome + browserstack-test: + runs-on: ubuntu-latest + uses: /.github/workflows/checkout-cache-build.yaml + steps: - name: BrowserStack Env Setup uses: browserstack/github-actions/setup-env@master with: From 8438b1ac6b5c438d7b1ae9588075786fcb6c4109 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Fri, 30 Dec 2022 12:52:19 +0100 Subject: [PATCH 076/191] fix workflow --- .github/workflows/test-execution.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index 85e3c54..ea67ce6 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -13,21 +13,21 @@ jobs: chrome: image: selenium/standalone-chrome options: --health-cmd '/opt/bin/check-grid.sh' - uses: /.github/workflows/checkout-cache-build.yaml + uses: ./.github/workflows/checkout-cache-build.yaml@main steps: - name: Run local tests run: mvn -B test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome testcontainers-test: runs-on: ubuntu-latest - uses: /.github/workflows/checkout-cache-build.yaml + uses: ./.github/workflows/checkout-cache-build.yaml@main steps: - name: Run local tests run: mvn -B test -Dtarget=testcontainers -Dbrowser=chrome browserstack-test: runs-on: ubuntu-latest - uses: /.github/workflows/checkout-cache-build.yaml + uses: ./.github/workflows/checkout-cache-build.yaml@main steps: - name: BrowserStack Env Setup uses: browserstack/github-actions/setup-env@master From a1bf67dcf6e00dbc3af54138484dfef1e37a1924 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Fri, 30 Dec 2022 12:57:08 +0100 Subject: [PATCH 077/191] fix workflow --- .github/workflows/checkout-cache-build.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/checkout-cache-build.yaml b/.github/workflows/checkout-cache-build.yaml index 8aa7709..1da6cef 100644 --- a/.github/workflows/checkout-cache-build.yaml +++ b/.github/workflows/checkout-cache-build.yaml @@ -1,5 +1,8 @@ name: Reusable checkout and cache +on: + workflow_call: + jobs: local-test: runs-on: ubuntu-latest From 6b33579d01c47ca767a8943884899228b7bc0b03 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Fri, 30 Dec 2022 12:57:48 +0100 Subject: [PATCH 078/191] fix workflow --- .github/workflows/checkout-cache-build.yaml | 3 --- .github/workflows/test-execution.yml | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/checkout-cache-build.yaml b/.github/workflows/checkout-cache-build.yaml index 1da6cef..8aa7709 100644 --- a/.github/workflows/checkout-cache-build.yaml +++ b/.github/workflows/checkout-cache-build.yaml @@ -1,8 +1,5 @@ name: Reusable checkout and cache -on: - workflow_call: - jobs: local-test: runs-on: ubuntu-latest diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index ea67ce6..8bb3792 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -1,5 +1,6 @@ name: Build and Test on: + workflow_call: push: branches: - main From 75de9de7199c7b580cc247578b58030739eb419d Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Fri, 30 Dec 2022 13:02:41 +0100 Subject: [PATCH 079/191] fix workflow --- .github/workflows/test-execution.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index 8bb3792..d3ebc11 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -14,21 +14,21 @@ jobs: chrome: image: selenium/standalone-chrome options: --health-cmd '/opt/bin/check-grid.sh' - uses: ./.github/workflows/checkout-cache-build.yaml@main + uses: ./.github/workflows/checkout-cache-build.yaml steps: - name: Run local tests run: mvn -B test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome testcontainers-test: runs-on: ubuntu-latest - uses: ./.github/workflows/checkout-cache-build.yaml@main + uses: ./.github/workflows/checkout-cache-build.yaml steps: - name: Run local tests run: mvn -B test -Dtarget=testcontainers -Dbrowser=chrome browserstack-test: runs-on: ubuntu-latest - uses: ./.github/workflows/checkout-cache-build.yaml@main + uses: ./.github/workflows/checkout-cache-build.yaml steps: - name: BrowserStack Env Setup uses: browserstack/github-actions/setup-env@master From d1d202548df7a7e60458d307928246a36e3ccc8c Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Fri, 30 Dec 2022 13:08:35 +0100 Subject: [PATCH 080/191] fix workflow --- .../{ => reusable}/checkout-cache-build.yaml | 0 .github/workflows/test-execution.yml | 12 +++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) rename .github/workflows/{ => reusable}/checkout-cache-build.yaml (100%) diff --git a/.github/workflows/checkout-cache-build.yaml b/.github/workflows/reusable/checkout-cache-build.yaml similarity index 100% rename from .github/workflows/checkout-cache-build.yaml rename to .github/workflows/reusable/checkout-cache-build.yaml diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index d3ebc11..db0903f 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -14,22 +14,28 @@ jobs: chrome: image: selenium/standalone-chrome options: --health-cmd '/opt/bin/check-grid.sh' - uses: ./.github/workflows/checkout-cache-build.yaml steps: + - name: Checkout, cache and build + run: ./.github/workflows/reusable/checkout-cache-build.yaml + - name: Run local tests run: mvn -B test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome testcontainers-test: runs-on: ubuntu-latest - uses: ./.github/workflows/checkout-cache-build.yaml steps: + - name: Checkout, cache and build + run: ./.github/workflows/reusable/checkout-cache-build.yaml + - name: Run local tests run: mvn -B test -Dtarget=testcontainers -Dbrowser=chrome browserstack-test: runs-on: ubuntu-latest - uses: ./.github/workflows/checkout-cache-build.yaml steps: + - name: Checkout, cache and build + run: ./.github/workflows/reusable/checkout-cache-build.yaml + - name: BrowserStack Env Setup uses: browserstack/github-actions/setup-env@master with: From f8aa0823861bdbe2ccaac1fd0080ad6f0ec80604 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Fri, 30 Dec 2022 13:09:53 +0100 Subject: [PATCH 081/191] fix workflow --- .github/workflows/test-execution.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index db0903f..e575f1d 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -16,7 +16,7 @@ jobs: options: --health-cmd '/opt/bin/check-grid.sh' steps: - name: Checkout, cache and build - run: ./.github/workflows/reusable/checkout-cache-build.yaml + run: .github/workflows/reusable/checkout-cache-build.yaml - name: Run local tests run: mvn -B test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome @@ -25,7 +25,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout, cache and build - run: ./.github/workflows/reusable/checkout-cache-build.yaml + run: .github/workflows/reusable/checkout-cache-build.yaml - name: Run local tests run: mvn -B test -Dtarget=testcontainers -Dbrowser=chrome @@ -34,7 +34,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout, cache and build - run: ./.github/workflows/reusable/checkout-cache-build.yaml + run: .github/workflows/reusable/checkout-cache-build.yaml - name: BrowserStack Env Setup uses: browserstack/github-actions/setup-env@master From 052cc6e52a1f6a608f47b98bc10ac992c43a9cc6 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Fri, 30 Dec 2022 13:22:38 +0100 Subject: [PATCH 082/191] fix workflow --- .../reusable/checkout-cache-build.yaml | 24 -------- .github/workflows/test-execution.yml | 55 ++++++++++++++++--- 2 files changed, 48 insertions(+), 31 deletions(-) delete mode 100644 .github/workflows/reusable/checkout-cache-build.yaml diff --git a/.github/workflows/reusable/checkout-cache-build.yaml b/.github/workflows/reusable/checkout-cache-build.yaml deleted file mode 100644 index 8aa7709..0000000 --- a/.github/workflows/reusable/checkout-cache-build.yaml +++ /dev/null @@ -1,24 +0,0 @@ -name: Reusable checkout and cache - -jobs: - local-test: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: 17 - distribution: adopt - - - name: Cache Maven packages - uses: actions/cache@v3 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - - name: Build with Maven - run: mvn -B -DskipTests package --file pom.xml diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index e575f1d..e5e2b1c 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -1,6 +1,5 @@ name: Build and Test on: - workflow_call: push: branches: - main @@ -15,8 +14,23 @@ jobs: image: selenium/standalone-chrome options: --health-cmd '/opt/bin/check-grid.sh' steps: - - name: Checkout, cache and build - run: .github/workflows/reusable/checkout-cache-build.yaml + - uses: actions/checkout@v3 + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: adopt + + - name: Cache Maven packages + uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Build with Maven + run: mvn -B -DskipTests package --file pom.xml - name: Run local tests run: mvn -B test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome @@ -24,8 +38,23 @@ jobs: testcontainers-test: runs-on: ubuntu-latest steps: - - name: Checkout, cache and build - run: .github/workflows/reusable/checkout-cache-build.yaml + - uses: actions/checkout@v3 + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: adopt + + - name: Cache Maven packages + uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Build with Maven + run: mvn -B -DskipTests package --file pom.xml - name: Run local tests run: mvn -B test -Dtarget=testcontainers -Dbrowser=chrome @@ -33,8 +62,20 @@ jobs: browserstack-test: runs-on: ubuntu-latest steps: - - name: Checkout, cache and build - run: .github/workflows/reusable/checkout-cache-build.yaml + - uses: actions/checkout@v3 + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: adopt + + - name: Cache Maven packages + uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- - name: BrowserStack Env Setup uses: browserstack/github-actions/setup-env@master From 72f3894012085942453a42f76ff5fd866bb024a9 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Fri, 30 Dec 2022 13:32:59 +0100 Subject: [PATCH 083/191] fix workflow --- .github/workflows/test-execution.yml | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index e5e2b1c..525ba60 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -35,30 +35,6 @@ jobs: - name: Run local tests run: mvn -B test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome - testcontainers-test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: 17 - distribution: adopt - - - name: Cache Maven packages - uses: actions/cache@v3 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - - name: Build with Maven - run: mvn -B -DskipTests package --file pom.xml - - - name: Run local tests - run: mvn -B test -Dtarget=testcontainers -Dbrowser=chrome - browserstack-test: runs-on: ubuntu-latest steps: From edab660a024858b2810049402381f8d87db2d4c8 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Fri, 30 Dec 2022 13:58:57 +0100 Subject: [PATCH 084/191] added testcontainers --- README.MD | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.MD b/README.MD index da24106..1909aad 100644 --- a/README.MD +++ b/README.MD @@ -5,6 +5,13 @@ **This project delivers to you a complete lean test architecture for your web tests using the best frameworks and practices.** +It has a complete solution to run tests in different ways: + +* local testing using the browser on your local machine +* parallel (or single) testing using Selenium Docker +* parallel (or single) testing using Browserstack +* local testing using TestContainers + ## Important information ### Know issues @@ -95,6 +102,8 @@ on `general.properties` file. Its usage is placed on the `BaseWeb` class before #### Local execution +##### Local machine + This execution type uses [WebDriverManager](https://github.com/bonigarcia/webdrivermanager) class to instantiate the web browsers. When the `target` is `local` the `createLocalDriver()` method is used from the `BrowserFactory` class to return the @@ -102,6 +111,15 @@ browser instance. The browser used in the test is placed on the `browser` property in the `general.properties` file. +##### Testcontainers + +This execution type uses the [WebDriver Containers](https://www.testcontainers.org/modules/webdriver_containers/) in +Testcontainers to run the tests in your machine, but using the Selenium docker images for Chrome or Firefox. + +When the `target` is `testcontainers` the `TargetFactory` uses the `createTestContainersInstance()` method to initialize +the container based on the browser set in the `browser` property. Currently, Testcontainers only supports Chrome and +Firefox. + #### Remote execution ##### Selenium Grid From b4941059b38b56e5ee45d772541ef55d7b04a914 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Fri, 30 Dec 2022 14:15:14 +0100 Subject: [PATCH 085/191] fix proeperties --- src/test/resources/general.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/general.properties b/src/test/resources/general.properties index 86a5fad..7e4dcdc 100644 --- a/src/test/resources/general.properties +++ b/src/test/resources/general.properties @@ -1,5 +1,5 @@ # target execution: local, selenium-grid, browserstack or testcontainers -target = testcontainers +target = local # browser to use for local and testcontainers execution browser = chrome From f4f8d7db902af89d7f3fc6c5f068d3b5641b518e Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Fri, 30 Dec 2022 14:37:12 +0100 Subject: [PATCH 086/191] disable browserstack job --- .github/workflows/test-execution.yml | 3 +++ src/test/resources/suites/browserstack.xml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index 525ba60..86890e3 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -35,7 +35,10 @@ jobs: - name: Run local tests run: mvn -B test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome +# disabled job to show it as a reference since the browserstack sdk dynamically loads classes and generates conflicts +# with the current libraries browserstack-test: + if: ${{ false }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/src/test/resources/suites/browserstack.xml b/src/test/resources/suites/browserstack.xml index b014007..6afcbae 100644 --- a/src/test/resources/suites/browserstack.xml +++ b/src/test/resources/suites/browserstack.xml @@ -1,5 +1,5 @@ - + From 5baf70caa5d66f8d4c1dda9b2511ba302403a9e5 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Mon, 13 Mar 2023 22:14:54 +0100 Subject: [PATCH 087/191] added http client due to selenium limitations --- src/test/java/com/eliasnogueira/BaseWeb.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/com/eliasnogueira/BaseWeb.java b/src/test/java/com/eliasnogueira/BaseWeb.java index 678bc58..b7965de 100644 --- a/src/test/java/com/eliasnogueira/BaseWeb.java +++ b/src/test/java/com/eliasnogueira/BaseWeb.java @@ -42,6 +42,7 @@ public abstract class BaseWeb { @BeforeSuite public void beforeSuite() { + System.setProperty("webdriver.http.factory", "jdk-http-client"); AllureManager.setAllureEnvironmentInformation(); } From be226573a1ea13633e5290b543674a71705c6e23 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Mon, 13 Mar 2023 22:15:06 +0100 Subject: [PATCH 088/191] added new browser data --- .../java/com/eliasnogueira/data/changeless/BrowserData.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/eliasnogueira/data/changeless/BrowserData.java b/src/main/java/com/eliasnogueira/data/changeless/BrowserData.java index e600752..810154d 100644 --- a/src/main/java/com/eliasnogueira/data/changeless/BrowserData.java +++ b/src/main/java/com/eliasnogueira/data/changeless/BrowserData.java @@ -32,4 +32,7 @@ private BrowserData() { public static final String START_MAXIMIZED = "--start-maximized"; public static final String DISABLE_INFOBARS = "--disable-infobars"; public static final String DISABLE_NOTIFICATIONS = "--disable-notifications"; + public static final String REMOTE_ALLOW_ORIGINS = "--remote-allow-origins=*"; + public static final String GENERIC_HEADLESS = "-headless"; + public static final String CHROME_HEADLESS = "--headless=new"; } From cab38c9db497a0f512dac8bd049bcd4f4c023fd6 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Mon, 13 Mar 2023 22:15:31 +0100 Subject: [PATCH 089/191] updated headless mode due to the selenium update --- .../eliasnogueira/driver/BrowserFactory.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java index 5b69f36..b44c9cd 100644 --- a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java +++ b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java @@ -26,7 +26,6 @@ import com.eliasnogueira.exceptions.HeadlessNotSupportedException; import io.github.bonigarcia.wdm.WebDriverManager; -import io.github.bonigarcia.wdm.config.DriverManagerType; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; @@ -39,8 +38,11 @@ import org.openqa.selenium.safari.SafariOptions; import static com.eliasnogueira.config.ConfigurationManager.configuration; +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; @@ -65,7 +67,9 @@ public ChromeOptions getOptions() { chromeOptions.addArguments(START_MAXIMIZED); chromeOptions.addArguments(DISABLE_INFOBARS); chromeOptions.addArguments(DISABLE_NOTIFICATIONS); - chromeOptions.setHeadless(configuration().headless()); + chromeOptions.addArguments(REMOTE_ALLOW_ORIGINS); + + if (configuration().headless()) chromeOptions.addArguments(CHROME_HEADLESS); return chromeOptions; } @@ -86,7 +90,8 @@ public WebDriver createDriver() { public FirefoxOptions getOptions() { var firefoxOptions = new FirefoxOptions(); firefoxOptions.addArguments(START_MAXIMIZED); - firefoxOptions.setHeadless(configuration().headless()); + + if (configuration().headless()) firefoxOptions.addArguments(GENERIC_HEADLESS); return firefoxOptions; } @@ -107,7 +112,8 @@ public WebDriver createDriver() { public EdgeOptions getOptions() { var edgeOptions = new EdgeOptions(); edgeOptions.addArguments(START_MAXIMIZED); - edgeOptions.setHeadless(configuration().headless()); + + if (configuration().headless()) edgeOptions.addArguments(GENERIC_HEADLESS); return edgeOptions; } @@ -138,18 +144,19 @@ public SafariOptions getOptions() { /** * Used to run local tests where the WebDriverManager will take care of the driver + * * @return a new WebDriver instance based on the browser set */ public abstract WebDriver createLocalDriver(); /** * Used to run the Browserstack tests + * * @return a new WebDriver instance based on the browser set */ public abstract WebDriver createDriver(); /** - * * @return a new AbstractDriverOptions instance based on the browser set */ public abstract AbstractDriverOptions getOptions(); From b773d9776beab8d68814692ce234919a9331d0ca Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Mon, 13 Mar 2023 22:16:00 +0100 Subject: [PATCH 090/191] test suite name renamed --- src/test/resources/suites/local.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/suites/local.xml b/src/test/resources/suites/local.xml index 741a2cf..bce93a4 100644 --- a/src/test/resources/suites/local.xml +++ b/src/test/resources/suites/local.xml @@ -1,7 +1,7 @@ - + From 338d88272e505271471793182b085edd7572de03 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Mon, 13 Mar 2023 22:16:40 +0100 Subject: [PATCH 091/191] added local-suite --- README.MD | 11 ++++++++++- .../java/com/eliasnogueira/driver/TargetFactory.java | 6 ++++-- src/main/java/com/eliasnogueira/enums/Target.java | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README.MD b/README.MD index 1909aad..5883875 100644 --- a/README.MD +++ b/README.MD @@ -90,9 +90,10 @@ Use this approach if you know that the page does not refresh. ### Execution types -There are three execution types: +There are different execution types: - `local` +- `local-suite` - `selenium-grid` - `browserstack` - `testcontainers` @@ -104,6 +105,8 @@ on `general.properties` file. Its usage is placed on the `BaseWeb` class before ##### Local machine +**This approach is automatically used when you run the test class in your IDE.** + This execution type uses [WebDriverManager](https://github.com/bonigarcia/webdrivermanager) class to instantiate the web browsers. When the `target` is `local` the `createLocalDriver()` method is used from the `BrowserFactory` class to return the @@ -111,6 +114,12 @@ browser instance. The browser used in the test is placed on the `browser` property in the `general.properties` file. +##### Local Suite + +This execution type also uses the [WebDriverManager](https://github.com/bonigarcia/webdrivermanager) to instantiate the +web browser. 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 This execution type uses the [WebDriver Containers](https://www.testcontainers.org/modules/webdriver_containers/) in diff --git a/src/main/java/com/eliasnogueira/driver/TargetFactory.java b/src/main/java/com/eliasnogueira/driver/TargetFactory.java index 1fc84cd..fa6ae6c 100644 --- a/src/main/java/com/eliasnogueira/driver/TargetFactory.java +++ b/src/main/java/com/eliasnogueira/driver/TargetFactory.java @@ -35,7 +35,8 @@ import java.net.URL; import static com.eliasnogueira.config.ConfigurationManager.configuration; -import static com.eliasnogueira.driver.BrowserFactory.*; +import static com.eliasnogueira.driver.BrowserFactory.CHROME; +import static com.eliasnogueira.driver.BrowserFactory.valueOf; import static java.lang.String.format; import static org.apache.commons.lang3.ObjectUtils.notEqual; @@ -48,6 +49,7 @@ public WebDriver createInstance(String browser) { return switch (target) { case LOCAL -> valueOf(configuration().browser().toUpperCase()).createLocalDriver(); + case LOCAL_SUITE -> valueOf(browser.toUpperCase()).createLocalDriver(); case BROWSERSTACK -> valueOf(browser.toUpperCase()).createDriver(); case SELENIUM_GRID -> createRemoteInstance(valueOf(browser.toUpperCase()).getOptions()); case TESTCONTAINERS -> @@ -74,7 +76,7 @@ private RemoteWebDriver createRemoteInstance(MutableCapabilities capability) { private RemoteWebDriver createTestContainersInstance(MutableCapabilities capabilities) { String browser = capabilities.getBrowserName(); - if (notEqual(browser, CHROME.toString().toLowerCase()) && notEqual(browser, CHROME.toString().toLowerCase())) { + if (notEqual(browser, CHROME.toString().toLowerCase())) { throw new IllegalArgumentException( format("Browser %s not supported for TestContainers", capabilities.getBrowserName())); } diff --git a/src/main/java/com/eliasnogueira/enums/Target.java b/src/main/java/com/eliasnogueira/enums/Target.java index ad14f52..09c4ec4 100644 --- a/src/main/java/com/eliasnogueira/enums/Target.java +++ b/src/main/java/com/eliasnogueira/enums/Target.java @@ -33,7 +33,7 @@ public enum Target { - LOCAL("local"), SELENIUM_GRID("selenium-grid"), BROWSERSTACK("browserstack"), + LOCAL("local"), LOCAL_SUITE("local-suite"), SELENIUM_GRID("selenium-grid"), BROWSERSTACK("browserstack"), TESTCONTAINERS("testcontainers"); private final String value; From 676b96ef5aeab4cd8395bcf9f486e4a3e20b78ab Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Mon, 13 Mar 2023 22:16:53 +0100 Subject: [PATCH 092/191] libraries update --- pom.xml | 68 +++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index f726796..f3d7a49 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.2.0 + 3.3.0 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -21,22 +21,28 @@ 3.10.1 1.9.9.1 - 4.7.2 - 7.7.0 - 3.23.1 - 1.7.0 - 2.19.0 - 5.3.1 + 4.8.1 + 7.7.1 + 3.24.2 + 1.8.0 + 2.20.0 + 5.3.2 1.0.12 - 2.20.1 + 2.21.0 2.11.2 1.0.0 https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline - 1.1.5 + 1.2.3 1.17.6 + + 3.6.3 + 2.0 + 2.11.0 + 4.13.2 + local @@ -47,10 +53,22 @@ ${selenium.version} + + org.seleniumhq.selenium + selenium-http-jdk-client + ${selenium.version} + + org.testng testng ${testng.version} + + + org.webjars + jquery + + @@ -98,6 +116,10 @@ com.google.guava guava + + commons-io + commons-io + @@ -134,6 +156,10 @@ commons-io commons-io + + junit + junit + @@ -143,6 +169,30 @@ ${testcontainers.selenium.version} + + + + + + org.webjars.bower + jquery + ${jquery.version} + + + + + org.yaml + snakeyaml + ${snakeyaml.version} + + + + + commons-io + commons-io + 2.11.0 + + From 33fcec7eda3e9586a41af6aa48b0b03db1ff5bcd Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Wed, 15 Mar 2023 18:31:48 +0100 Subject: [PATCH 093/191] actions update --- .github/workflows/test-execution.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index 86890e3..47a656d 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -30,10 +30,10 @@ jobs: ${{ runner.os }}-maven- - name: Build with Maven - run: mvn -B -DskipTests package --file pom.xml + run: mvn -B -q -DskipTests package --file pom.xml - name: Run local tests - run: mvn -B test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome + run: mvn -B -q test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome # disabled job to show it as a reference since the browserstack sdk dynamically loads classes and generates conflicts # with the current libraries @@ -69,7 +69,7 @@ jobs: local-testing: start - name: Run browserstack tests - run: mvn -B test -Pbrowserstack + run: mvn -B -q test -Pbrowserstack - name: Start BrowserStackLocal Tunnel uses: browserstack/github-actions/setup-local@master From d8f48dfbccb5878638ede41ddd7ea1e6d9b91fee Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Wed, 15 Mar 2023 18:46:09 +0100 Subject: [PATCH 094/191] excluded junit from exclusions --- pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pom.xml b/pom.xml index f3d7a49..ab8fd54 100644 --- a/pom.xml +++ b/pom.xml @@ -156,10 +156,6 @@ commons-io commons-io - - junit - junit - @@ -170,7 +166,6 @@ - From e54769c5f3a67d6e980e164843849e6fa12a07a0 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Wed, 15 Mar 2023 18:51:34 +0100 Subject: [PATCH 095/191] removal of browserstack sdk --- README.MD | 12 ----- browserstack.yml | 27 ----------- pom.xml | 48 +------------------ .../eliasnogueira/driver/TargetFactory.java | 1 - .../java/com/eliasnogueira/enums/Target.java | 3 +- 5 files changed, 2 insertions(+), 89 deletions(-) delete mode 100644 browserstack.yml diff --git a/README.MD b/README.MD index 5883875..a30af03 100644 --- a/README.MD +++ b/README.MD @@ -9,7 +9,6 @@ It has a complete solution to run tests in different ways: * local testing using the browser on your local machine * parallel (or single) testing using Selenium Docker -* parallel (or single) testing using Browserstack * local testing using TestContainers ## Important information @@ -95,7 +94,6 @@ There are different execution types: - `local` - `local-suite` - `selenium-grid` -- `browserstack` - `testcontainers` The `TargetFactory` class will resolve the target execution based on the `target` property value located @@ -150,16 +148,6 @@ file should work. You can take a look at the [Execution with Docker Selenium Distributed](#execution-with-docker-selenium-distributed) to run the parallel tests using this example. -##### Browserstack - -The Browserstack approach runs the tests in the browserstack cloud. - -When the `target` is `browserstack` the `createDriver` method is used from the `BrowserFactory` to return the browser(s) -set in the `src/test/resources/suites/browserstack.xml` test suite. - -You can take a look at the [Execution with Browserstack](#execution-with-browserstack) -to run the parallel tests using this example. - #### BrowserFactory class This Factory class is a Java enum that has all implemented browsers to use during the test execution. diff --git a/browserstack.yml b/browserstack.yml deleted file mode 100644 index d43a8ac..0000000 --- a/browserstack.yml +++ /dev/null @@ -1,27 +0,0 @@ -# Set BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY as env variables -# instead of adding it here -#userName: USER -#accessKey: ACCESS_KEY -buildName: book-a-room-test-1 -projectName: Selenium Java Lean Test Architecture -framework: testng -platforms: - - os: Windows - osVersion: 11 - browserName: Chrome - browserVersion: 103.0 - - os: Windows - osVersion: 10 - browserName: Firefox - browserVersion: 102.0 - - os: OS X - osVersion: Big Sur - browserName: Safari - browserVersion: 14.1 -parallelsPerPlatform: 1 - -source: selenium-lean-java-architecture -browserstackLocal: true -debug: false -networkLogs: false -consoleLogs: errors diff --git a/pom.xml b/pom.xml index ab8fd54..413ed01 100644 --- a/pom.xml +++ b/pom.xml @@ -34,7 +34,6 @@ https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline - 1.2.3 1.17.6 @@ -147,18 +146,6 @@ - - com.browserstack - browserstack-java-sdk - ${browserstack-java-sdk.version} - - - commons-io - commons-io - - - - org.testcontainers selenium @@ -210,39 +197,6 @@ - - browserstack - - browserstack - - - - - maven-dependency-plugin - - - getClasspathFilenames - - properties - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - src/test/resources/suites/browserstack.xml - - - -javaagent:${com.browserstack:browserstack-java-sdk:jar} - - - - - - @@ -289,4 +243,4 @@ - \ No newline at end of file + diff --git a/src/main/java/com/eliasnogueira/driver/TargetFactory.java b/src/main/java/com/eliasnogueira/driver/TargetFactory.java index fa6ae6c..6e9ede6 100644 --- a/src/main/java/com/eliasnogueira/driver/TargetFactory.java +++ b/src/main/java/com/eliasnogueira/driver/TargetFactory.java @@ -50,7 +50,6 @@ public WebDriver createInstance(String browser) { return switch (target) { case LOCAL -> valueOf(configuration().browser().toUpperCase()).createLocalDriver(); case LOCAL_SUITE -> valueOf(browser.toUpperCase()).createLocalDriver(); - case BROWSERSTACK -> valueOf(browser.toUpperCase()).createDriver(); case SELENIUM_GRID -> createRemoteInstance(valueOf(browser.toUpperCase()).getOptions()); case TESTCONTAINERS -> createTestContainersInstance(valueOf(configuration().browser().toUpperCase()).getOptions()); diff --git a/src/main/java/com/eliasnogueira/enums/Target.java b/src/main/java/com/eliasnogueira/enums/Target.java index 09c4ec4..0b7618d 100644 --- a/src/main/java/com/eliasnogueira/enums/Target.java +++ b/src/main/java/com/eliasnogueira/enums/Target.java @@ -33,8 +33,7 @@ public enum Target { - LOCAL("local"), LOCAL_SUITE("local-suite"), SELENIUM_GRID("selenium-grid"), BROWSERSTACK("browserstack"), - TESTCONTAINERS("testcontainers"); + LOCAL("local"), LOCAL_SUITE("local-suite"), SELENIUM_GRID("selenium-grid"), TESTCONTAINERS("testcontainers"); private final String value; private static final Map ENUM_MAP; From 7bcb31f1748b3d5cc78ec2d6a7a7767c13da6edc Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Thu, 4 May 2023 16:50:34 +0200 Subject: [PATCH 096/191] moved the pipelines to a different folder --- {pipeline_as_code => .sdlc}/.gitlab-ci.yml | 0 {pipeline_as_code => .sdlc}/Jenkinsfile | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {pipeline_as_code => .sdlc}/.gitlab-ci.yml (100%) rename {pipeline_as_code => .sdlc}/Jenkinsfile (100%) diff --git a/pipeline_as_code/.gitlab-ci.yml b/.sdlc/.gitlab-ci.yml similarity index 100% rename from pipeline_as_code/.gitlab-ci.yml rename to .sdlc/.gitlab-ci.yml diff --git a/pipeline_as_code/Jenkinsfile b/.sdlc/Jenkinsfile similarity index 100% rename from pipeline_as_code/Jenkinsfile rename to .sdlc/Jenkinsfile From aeaa19e73ae8612d6830b9fe0956c38dbcc9d0c5 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Thu, 4 May 2023 16:51:04 +0200 Subject: [PATCH 097/191] fix small issue with immutable map and configuration check --- src/main/java/com/eliasnogueira/report/AllureManager.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/eliasnogueira/report/AllureManager.java b/src/main/java/com/eliasnogueira/report/AllureManager.java index 24e844a..4fabc20 100644 --- a/src/main/java/com/eliasnogueira/report/AllureManager.java +++ b/src/main/java/com/eliasnogueira/report/AllureManager.java @@ -31,6 +31,7 @@ import io.qameta.allure.Attachment; import org.openqa.selenium.TakesScreenshot; +import java.util.HashMap; import java.util.Map; import static com.eliasnogueira.config.ConfigurationManager.configuration; @@ -42,16 +43,16 @@ private AllureManager() { } public static void setAllureEnvironmentInformation() { - var basicInfo = Map.of( + var basicInfo = new HashMap<>(Map.of( "Test URL", configuration().url(), "Target execution", configuration().target(), "Global timeout", String.valueOf(configuration().timeout()), "Headless mode", String.valueOf(configuration().headless()), "Faker locale", configuration().faker(), "Local browser", configuration().browser() - ); + )); - if (configuration().target().equals(Target.SELENIUM_GRID)) { + if (configuration().target().equals(Target.SELENIUM_GRID.name())) { var gridMap = Map.of("Grid URL", configuration().gridUrl(), "Grid port", configuration().gridPort()); basicInfo.putAll(gridMap); } From cba9e18d7e98898c450b70160e5c074020905e8a Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Thu, 4 May 2023 16:51:35 +0200 Subject: [PATCH 098/191] removal of specific build class to use the record instead --- .../eliasnogueira/model/BookingBuilder.java | 77 ------------------- 1 file changed, 77 deletions(-) delete mode 100644 src/main/java/com/eliasnogueira/model/BookingBuilder.java diff --git a/src/main/java/com/eliasnogueira/model/BookingBuilder.java b/src/main/java/com/eliasnogueira/model/BookingBuilder.java deleted file mode 100644 index 82da658..0000000 --- a/src/main/java/com/eliasnogueira/model/BookingBuilder.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2018 Elias Nogueira - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.eliasnogueira.model; - -import com.eliasnogueira.enums.RoomType; - -public class BookingBuilder { - - private String email; - private String country; - private String password; - private String dailyBudget; - private Boolean newsletter; - private RoomType roomType; - private String roomDescription; - - public BookingBuilder email(String email) { - this.email = email; - return this; - } - - public BookingBuilder country(String country) { - this.country = country; - return this; - } - - public BookingBuilder password(String password) { - this.password = password; - return this; - } - - public BookingBuilder dailyBudget(String dailyBudget) { - this.dailyBudget = dailyBudget; - return this; - } - - public BookingBuilder newsletter(Boolean newsletter) { - this.newsletter = newsletter; - return this; - } - - public BookingBuilder roomType(RoomType roomType) { - this.roomType = roomType; - return this; - } - - public BookingBuilder roomDescription(String roomDescription) { - this.roomDescription = roomDescription; - return this; - } - - public Booking build() { - return new Booking(email, country, password, dailyBudget, newsletter, roomType, roomDescription); - } -} \ No newline at end of file From a4f08ce6228b142ed637f13962b8bab887a7b2bc Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Thu, 4 May 2023 16:51:55 +0200 Subject: [PATCH 099/191] changed class to record with the builder pattern --- .../java/com/eliasnogueira/model/Booking.java | 140 +++++++----------- 1 file changed, 53 insertions(+), 87 deletions(-) diff --git a/src/main/java/com/eliasnogueira/model/Booking.java b/src/main/java/com/eliasnogueira/model/Booking.java index 314da58..01bd9b4 100644 --- a/src/main/java/com/eliasnogueira/model/Booking.java +++ b/src/main/java/com/eliasnogueira/model/Booking.java @@ -26,90 +26,56 @@ import com.eliasnogueira.enums.RoomType; -public class Booking { - - private String email; - private String country; - private String password; - private String dailyBudget; - private Boolean newsletter; - private RoomType roomType; - private String roomDescription; - - public Booking(String email, String country, String password, String dailyBudget, Boolean newsletter, - RoomType roomType, String roomDescription) { - this.email = email; - this.country = country; - this.password = password; - this.dailyBudget = dailyBudget; - this.newsletter = newsletter; - this.roomType = roomType; - this.roomDescription = roomDescription; - } - - public Booking() { - } - - public String getEmail() { - return this.email; - } - - public String getCountry() { - return this.country; - } - - public String getPassword() { - return this.password; - } - - public String getDailyBudget() { - return this.dailyBudget; - } - - public Boolean getNewsletter() { - return this.newsletter; - } - - public String getRoomType() { - return this.roomType.get(); - } - - public String getRoomDescription() { - return this.roomDescription; - } - - public void setEmail(String email) { - this.email = email; - } - - public void setCountry(String country) { - this.country = country; - } - - public void setPassword(String password) { - this.password = password; - } - - public void setDailyBudget(String dailyBudget) { - this.dailyBudget = dailyBudget; - } - - public void setNewsletter(Boolean newsletter) { - this.newsletter = newsletter; - } - - public void setRoomType(RoomType roomType) { - this.roomType = roomType; - } - - public void setRoomDescription(String roomDescription) { - this.roomDescription = roomDescription; - } - - public String toString() { - return "Booking(email=" + this.getEmail() + ", country=" + this.getCountry() + ", dailyBudget=" + - this.getDailyBudget() + ", newsletter=" + this.getNewsletter() + ", roomType=" - + this.getRoomType() + ", roomDescription=" + this.getRoomDescription() + ")"; - } - -} +public record Booking(String email, String country, String password, String dailyBudget, Boolean newsletter, + RoomType roomType, String roomDescription) { + + public static final class BookingBuilder { + + private String email; + private String country; + private String password; + private String dailyBudget; + private Boolean newsletter; + private RoomType roomType; + private String roomDescription; + + public BookingBuilder email(String email) { + this.email = email; + return this; + } + + public BookingBuilder country(String country) { + this.country = country; + return this; + } + + public BookingBuilder password(String password) { + this.password = password; + return this; + } + + public BookingBuilder dailyBudget(String dailyBudget) { + this.dailyBudget = dailyBudget; + return this; + } + + public BookingBuilder newsletter(Boolean newsletter) { + this.newsletter = newsletter; + return this; + } + + public BookingBuilder roomType(RoomType roomType) { + this.roomType = roomType; + return this; + } + + public BookingBuilder roomDescription(String roomDescription) { + this.roomDescription = roomDescription; + return this; + } + + public Booking build() { + return new Booking(email, country, password, dailyBudget, newsletter, roomType, roomDescription); + } + } +} \ No newline at end of file From 8174cca67d8a7eb37c6c5e1cf30a5947ea3fa1f7 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Thu, 4 May 2023 16:52:36 +0200 Subject: [PATCH 100/191] updated the builder class --- .../eliasnogueira/data/dynamic/BookingDataFactory.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java b/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java index f692852..d98633c 100644 --- a/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java +++ b/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java @@ -24,15 +24,14 @@ package com.eliasnogueira.data.dynamic; -import net.datafaker.Faker; import com.eliasnogueira.enums.RoomType; - -import java.util.Locale; import com.eliasnogueira.model.Booking; -import com.eliasnogueira.model.BookingBuilder; +import net.datafaker.Faker; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import java.util.Locale; + import static com.eliasnogueira.config.ConfigurationManager.configuration; public final class BookingDataFactory { @@ -44,7 +43,7 @@ private BookingDataFactory() { } public static Booking createBookingData() { - var booking = new BookingBuilder(). + var booking = new Booking.BookingBuilder(). email(faker.internet().emailAddress()). country(returnRandomCountry()). password(faker.internet().password()). From dac2209fde53194c9283fc690e9b4f38da243f64 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Thu, 4 May 2023 16:52:53 +0200 Subject: [PATCH 101/191] updated the model class usage --- .../java/com/eliasnogueira/test/BookRoomWebTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/java/com/eliasnogueira/test/BookRoomWebTest.java b/src/test/java/com/eliasnogueira/test/BookRoomWebTest.java index 61dae8e..7471352 100644 --- a/src/test/java/com/eliasnogueira/test/BookRoomWebTest.java +++ b/src/test/java/com/eliasnogueira/test/BookRoomWebTest.java @@ -39,19 +39,19 @@ public void bookARoom() { var bookingInformation = BookingDataFactory.createBookingData(); var accountPage = new AccountPage(); - accountPage.fillEmail(bookingInformation.getEmail()); - accountPage.fillPassword(bookingInformation.getPassword()); - accountPage.selectCountry(bookingInformation.getCountry()); - accountPage.selectBudget(bookingInformation.getDailyBudget()); + accountPage.fillEmail(bookingInformation.email()); + accountPage.fillPassword(bookingInformation.password()); + accountPage.selectCountry(bookingInformation.country()); + accountPage.selectBudget(bookingInformation.dailyBudget()); accountPage.clickNewsletter(); accountPage.next(); var roomPage = new RoomPage(); - roomPage.selectRoomType(bookingInformation.getRoomType()); + roomPage.selectRoomType(bookingInformation.roomType().get()); roomPage.next(); var detailPage = new DetailPage(); - detailPage.fillRoomDescription(bookingInformation.getRoomDescription()); + detailPage.fillRoomDescription(bookingInformation.roomDescription()); detailPage.finish(); assertThat(detailPage.getAlertMessage()) From c6fab83939fddb813b04a69719a7d6ba16b34a51 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Thu, 4 May 2023 16:53:10 +0200 Subject: [PATCH 102/191] removal of browserstack specific code --- .github/workflows/test-execution.yml | 41 ------------------- .../eliasnogueira/driver/BrowserFactory.java | 29 +------------ src/test/resources/suites/browserstack.xml | 11 ----- 3 files changed, 1 insertion(+), 80 deletions(-) delete mode 100644 src/test/resources/suites/browserstack.xml diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index 47a656d..fd99162 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -34,44 +34,3 @@ jobs: - name: Run local tests run: mvn -B -q test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome - -# disabled job to show it as a reference since the browserstack sdk dynamically loads classes and generates conflicts -# with the current libraries - browserstack-test: - if: ${{ false }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: 17 - distribution: adopt - - - name: Cache Maven packages - uses: actions/cache@v3 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - - name: BrowserStack Env Setup - uses: browserstack/github-actions/setup-env@master - with: - username: ${{ secrets.BROWSERSTACK_USERNAME }} - access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} - project-name: selenium-lean-java-architecture - - - name: Start BrowserStackLocal Tunnel - uses: browserstack/github-actions/setup-local@master - with: - local-testing: start - - - name: Run browserstack tests - run: mvn -B -q test -Pbrowserstack - - - name: Start BrowserStackLocal Tunnel - uses: browserstack/github-actions/setup-local@master - with: - local-testing: stop \ No newline at end of file diff --git a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java index b44c9cd..39036f0 100644 --- a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java +++ b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java @@ -56,11 +56,6 @@ public WebDriver createLocalDriver() { return new ChromeDriver(getOptions()); } - @Override - public WebDriver createDriver() { - return new ChromeDriver(); - } - @Override public ChromeOptions getOptions() { var chromeOptions = new ChromeOptions(); @@ -81,11 +76,6 @@ public WebDriver createLocalDriver() { return new FirefoxDriver(getOptions()); } - @Override - public WebDriver createDriver() { - return new FirefoxDriver(getOptions()); - } - @Override public FirefoxOptions getOptions() { var firefoxOptions = new FirefoxOptions(); @@ -103,11 +93,6 @@ public WebDriver createLocalDriver() { return new EdgeDriver(getOptions()); } - @Override - public WebDriver createDriver() { - return new EdgeDriver(getOptions()); - } - @Override public EdgeOptions getOptions() { var edgeOptions = new EdgeOptions(); @@ -125,11 +110,6 @@ public WebDriver createLocalDriver() { return new SafariDriver(getOptions()); } - @Override - public WebDriver createDriver() { - return new SafariDriver(getOptions()); - } - @Override public SafariOptions getOptions() { var safariOptions = new SafariOptions(); @@ -142,20 +122,13 @@ public SafariOptions getOptions() { } }; - /** + /**n * Used to run local tests where the WebDriverManager will take care of the driver * * @return a new WebDriver instance based on the browser set */ public abstract WebDriver createLocalDriver(); - /** - * Used to run the Browserstack tests - * - * @return a new WebDriver instance based on the browser set - */ - public abstract WebDriver createDriver(); - /** * @return a new AbstractDriverOptions instance based on the browser set */ diff --git a/src/test/resources/suites/browserstack.xml b/src/test/resources/suites/browserstack.xml deleted file mode 100644 index 6afcbae..0000000 --- a/src/test/resources/suites/browserstack.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - From 382c4f00e9f4440ef61572d019a29175ecb589c4 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Thu, 4 May 2023 16:53:32 +0200 Subject: [PATCH 103/191] removal of browserstack specific code --- src/test/resources/general.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/general.properties b/src/test/resources/general.properties index 7e4dcdc..379ffc5 100644 --- a/src/test/resources/general.properties +++ b/src/test/resources/general.properties @@ -1,4 +1,4 @@ -# target execution: local, selenium-grid, browserstack or testcontainers +# target execution: local, selenium-grid or testcontainers target = local # browser to use for local and testcontainers execution From 94b3265401042d2b2a6afedbf5f89ff1efda37c6 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Thu, 4 May 2023 16:53:42 +0200 Subject: [PATCH 104/191] library update --- pom.xml | 49 +++++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/pom.xml b/pom.xml index 413ed01..8206c08 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.3.0 + 3.3.1 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -21,26 +21,28 @@ 3.10.1 1.9.9.1 - 4.8.1 + 4.9.0 7.7.1 3.24.2 - 1.8.0 + 1.9.0 2.20.0 5.3.2 1.0.12 - 2.21.0 + 2.22.0 2.11.2 1.0.0 https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline - 1.17.6 + 1.18.0 3.6.3 2.0 2.11.0 4.13.2 + 2.15.0 + 1.70 local @@ -110,16 +112,6 @@ io.github.bonigarcia webdrivermanager ${webdrivermanager.version} - - - com.google.guava - guava - - - commons-io - commons-io - - @@ -154,11 +146,23 @@ - + - org.webjars.bower - jquery - ${jquery.version} + com.fasterxml.jackson.core + jackson-databind + ${jackson-databind.version} + + + + commons-io + commons-io + 2.11.0 + + + + org.bouncycastle + bcprov-jdk15on + ${bcprov-jdk15on.version} @@ -168,13 +172,6 @@ ${snakeyaml.version} - - - commons-io - commons-io - 2.11.0 - - From 0f0fddc7dd9c6b70b39142208756abedacf5260c Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Thu, 4 May 2023 16:53:55 +0200 Subject: [PATCH 105/191] removal of browserstack --- README.MD | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/README.MD b/README.MD index a30af03..960efc0 100644 --- a/README.MD +++ b/README.MD @@ -155,7 +155,7 @@ Each browser is an `enum`, and each enum implements three methods: * `createLocalDriver()`: creates the browser instance for the local execution. The browser driver is automatically managed by the WebDriverManager library -* `createDriver()`: creates the browser instance for the remote execution using the Browserstack cloud +* `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 @@ -247,25 +247,6 @@ Please note that you need to do the following actions before running it in paral * Start the Grid by running the following command inside the `grid` folder * `docker-compose up` -#### Execution with Browserstack - -This project uses -the [Browserstack SDK](https://www.browserstack.com/docs/automate/selenium/browserstack-sdk/core-concepts) -to run the tests in the Browserstack cloud using the `browserstack.yml` file in the project root directory. - -You need a username and access key to run the tests and, For education purposes, you can set it in -the `browserstack.yml` file, but the recommended way is to set it as an environment variable in your local machine. - -To run the test in the Browserstack cloud, you need to: - -* set the username and access key in the `browserstack.yml` file - or [create the related environment variables](https://automate.browserstack.com/dashboard/v2/quick-start/setup-browserstack-sdk) -* run the tests using the following command: `mvn test -Pbrowserstack` - -The tests will only run using the `browserstack` profile because the Browserstack SDK is configured as a Java Agent, so -it's there only -for these tests. It's also worth to mention that the profile automatically sets the `target` property to `browserstack`. - ### Configuration files This project uses a library called [Owner](http://owner.aeonbits.org/). You can find the class related to the property From 8ef480750de0902b0b431169a0fbda0bd666b351 Mon Sep 17 00:00:00 2001 From: mdiwakar Date: Mon, 26 Jun 2023 10:49:36 -0700 Subject: [PATCH 106/191] 188: support Firefox and Microsoft Edge 188: support Firefox and Microsoft Edge capabilities on testcontainers execution --- .sdlc/Jenkinsfile | 2 +- pom.xml | 6 ++-- .../eliasnogueira/driver/BrowserFactory.java | 1 + .../eliasnogueira/driver/TargetFactory.java | 28 +++++++++++++------ src/test/resources/general.properties | 6 ++-- 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/.sdlc/Jenkinsfile b/.sdlc/Jenkinsfile index 21899b8..e70fbba 100644 --- a/.sdlc/Jenkinsfile +++ b/.sdlc/Jenkinsfile @@ -2,7 +2,7 @@ node { def mvnHome stage('Preparation') { - git 'https://github.com/eliasnogueira/selenium-java-lean-test-achitecture.git' + git 'https://github.com/mdiwakar/selenium-java-lean-test-achitecture.git' mvnHome = tool 'M3' } diff --git a/pom.xml b/pom.xml index 8206c08..d6878eb 100644 --- a/pom.xml +++ b/pom.xml @@ -9,8 +9,8 @@ 3.3.1 - scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git - scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git + scm:git@github.com:mdiwakar/selenium-java-lean-test-architecture.git + scm:git@github.com:mdiwakar/selenium-java-lean-test-architecture.git @@ -34,7 +34,7 @@ https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline - 1.18.0 + 1.18.3 3.6.3 diff --git a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java index 39036f0..59e2ba5 100644 --- a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java +++ b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java @@ -37,6 +37,7 @@ import org.openqa.selenium.safari.SafariDriver; import org.openqa.selenium.safari.SafariOptions; + import static com.eliasnogueira.config.ConfigurationManager.configuration; import static com.eliasnogueira.data.changeless.BrowserData.CHROME_HEADLESS; import static com.eliasnogueira.data.changeless.BrowserData.DISABLE_INFOBARS; diff --git a/src/main/java/com/eliasnogueira/driver/TargetFactory.java b/src/main/java/com/eliasnogueira/driver/TargetFactory.java index 6e9ede6..861a5d7 100644 --- a/src/main/java/com/eliasnogueira/driver/TargetFactory.java +++ b/src/main/java/com/eliasnogueira/driver/TargetFactory.java @@ -27,16 +27,19 @@ import com.eliasnogueira.enums.Target; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.openqa.selenium.Capabilities; import org.openqa.selenium.MutableCapabilities; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.chrome.ChromeOptions; +import org.openqa.selenium.edge.EdgeOptions; +import org.openqa.selenium.firefox.FirefoxOptions; import org.openqa.selenium.remote.RemoteWebDriver; import org.testcontainers.containers.BrowserWebDriverContainer; import java.net.URL; import static com.eliasnogueira.config.ConfigurationManager.configuration; -import static com.eliasnogueira.driver.BrowserFactory.CHROME; -import static com.eliasnogueira.driver.BrowserFactory.valueOf; +import static com.eliasnogueira.driver.BrowserFactory.*; import static java.lang.String.format; import static org.apache.commons.lang3.ObjectUtils.notEqual; @@ -74,16 +77,23 @@ private RemoteWebDriver createRemoteInstance(MutableCapabilities capability) { private RemoteWebDriver createTestContainersInstance(MutableCapabilities capabilities) { String browser = capabilities.getBrowserName(); + BrowserWebDriverContainer driverContainer = null ; + if (browser.equalsIgnoreCase( CHROME.toString())) { - if (notEqual(browser, CHROME.toString().toLowerCase())) { + driverContainer = new BrowserWebDriverContainer<>() + .withCapabilities(new ChromeOptions()); + } else if (browser.equalsIgnoreCase( FIREFOX.toString())) { + driverContainer = new BrowserWebDriverContainer<>() + .withCapabilities(new FirefoxOptions()); + } else if (browser.equalsIgnoreCase( "MicrosoftEdge")) { + driverContainer = new BrowserWebDriverContainer<>() + .withCapabilities(new EdgeOptions()); + }else { throw new IllegalArgumentException( - format("Browser %s not supported for TestContainers", capabilities.getBrowserName())); + format("Browser %s not supported for TestContainers", capabilities.getBrowserName())); } + driverContainer.start(); + return new RemoteWebDriver(driverContainer.getSeleniumAddress(), capabilities); - try (BrowserWebDriverContainer driverContainer = new BrowserWebDriverContainer<>().withCapabilities(capabilities)) { - driverContainer.start(); - - return new RemoteWebDriver(driverContainer.getSeleniumAddress(), capabilities); - } } } diff --git a/src/test/resources/general.properties b/src/test/resources/general.properties index 379ffc5..de00661 100644 --- a/src/test/resources/general.properties +++ b/src/test/resources/general.properties @@ -1,8 +1,8 @@ # target execution: local, selenium-grid or testcontainers -target = local +target = testcontainers # browser to use for local and testcontainers execution -browser = chrome +browser = edge # initial URL url.base = http://eliasnogueira.com/external/selenium-java-architecture/ @@ -11,7 +11,7 @@ url.base = http://eliasnogueira.com/external/selenium-java-architecture/ timeout = 3 # datafaker locale -faker.locale = pt-BR +faker.locale = en-US # headless mode only for chrome or firefox and local execution headless = false From 268450ead1f0e9b86d39dbfa5ce3bd1b4708c466 Mon Sep 17 00:00:00 2001 From: mdiwakar Date: Mon, 26 Jun 2023 11:30:52 -0700 Subject: [PATCH 107/191] 188: Update README.MD file Update README file for recent Firefox and Edge container support. --- CONTRIBUTING.md | 2 +- README.MD | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6234999..21a0ef8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,7 +11,7 @@ Do not forget to add a _label_ on the issue or feature. Excellent! Thank you to help me out! You're going to need a few things first: -* JDK 11+ +* JDK 17+ * [Configure your IDE](https://projectlombok.org/setup/overview) in order to support Lombok. ## Send a pull request diff --git a/README.MD b/README.MD index 960efc0..b1d95ae 100644 --- a/README.MD +++ b/README.MD @@ -10,6 +10,7 @@ It has a complete solution to run tests in different ways: * local testing using the browser on your local machine * parallel (or single) testing using Selenium Docker * local testing using TestContainers +* Distributed execution using Selenium Grid ## Important information @@ -43,6 +44,7 @@ This project uses the following languages and frameworks: * [Log4J2](https://logging.apache.org/log4j/2.x/) as the logging management strategy * [WebDriverManager](https://github.com/bonigarcia/webdrivermanager) as the Selenium binaries management * [Owner](http://owner.aeonbits.org/) to minimize the code to handle the properties file +* [TestContainers] (https://java.testcontainers.org/modules/webdriver_containers/) Webdriver Containers ## Test architecture @@ -61,6 +63,7 @@ You will see the following items in this architecture: * [Test Data Factory](#test-data-factory) * [Profiles executors on pom.xml](#profiles-executors-on-pomxml) * [Pipeline as a code](#pipeline-as-a-code) +* [Test environment abstraction](#execution-with-docker-selenium-distributed) Do you have any other items to add to this test architecture? Please do a pull request or open an issue to discuss. @@ -240,9 +243,10 @@ This means that Docker Selenium will start a container test for a targeting brow Please note that you need to do the following actions before running it in parallel: * Docker installed -* Pull the images for Chrome and Firefox - * `docker pull selenium-standalog-chrome` - * `docker pull selenium-standalog-firefox` +* Pull the images for Chrome 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` * 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` From eb58b72cbea74d6e7e8692788efea802b3c6ed69 Mon Sep 17 00:00:00 2001 From: mdiwakar Date: Sun, 2 Jul 2023 10:32:40 -0700 Subject: [PATCH 108/191] 118 modified the changes as per code review 118 modified the changes as per code review --- .sdlc/Jenkinsfile | 2 +- .../eliasnogueira/driver/BrowserFactory.java | 38 ++++++++++++++++++- .../eliasnogueira/driver/TargetFactory.java | 33 +--------------- 3 files changed, 40 insertions(+), 33 deletions(-) diff --git a/.sdlc/Jenkinsfile b/.sdlc/Jenkinsfile index e70fbba..21899b8 100644 --- a/.sdlc/Jenkinsfile +++ b/.sdlc/Jenkinsfile @@ -2,7 +2,7 @@ node { def mvnHome stage('Preparation') { - git 'https://github.com/mdiwakar/selenium-java-lean-test-achitecture.git' + git 'https://github.com/eliasnogueira/selenium-java-lean-test-achitecture.git' mvnHome = tool 'M3' } diff --git a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java index 59e2ba5..450c0d4 100644 --- a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java +++ b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java @@ -34,8 +34,10 @@ import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.firefox.FirefoxOptions; import org.openqa.selenium.remote.AbstractDriverOptions; +import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.safari.SafariDriver; import org.openqa.selenium.safari.SafariOptions; +import org.testcontainers.containers.BrowserWebDriverContainer; import static com.eliasnogueira.config.ConfigurationManager.configuration; @@ -47,6 +49,7 @@ import static com.eliasnogueira.data.changeless.BrowserData.START_MAXIMIZED; import static java.lang.Boolean.TRUE; + public enum BrowserFactory { CHROME { @@ -56,7 +59,15 @@ public WebDriver createLocalDriver() { return new ChromeDriver(getOptions()); } + @Override + public WebDriver createTestContainerDriver() { + BrowserWebDriverContainer driverContainer = new BrowserWebDriverContainer<>() + .withCapabilities(new ChromeOptions()); + driverContainer.start(); + return new RemoteWebDriver(driverContainer.getSeleniumAddress(), new ChromeOptions()); + + } @Override public ChromeOptions getOptions() { var chromeOptions = new ChromeOptions(); @@ -76,8 +87,16 @@ public WebDriver createLocalDriver() { return new FirefoxDriver(getOptions()); } - @Override + public WebDriver createTestContainerDriver() { + BrowserWebDriverContainer driverContainer = new BrowserWebDriverContainer<>() + .withCapabilities(new FirefoxOptions()); + driverContainer.start(); + return new RemoteWebDriver(driverContainer.getSeleniumAddress(), new FirefoxOptions()); + + + } + @Override public FirefoxOptions getOptions() { var firefoxOptions = new FirefoxOptions(); firefoxOptions.addArguments(START_MAXIMIZED); @@ -94,6 +113,14 @@ public WebDriver createLocalDriver() { return new EdgeDriver(getOptions()); } + public WebDriver createTestContainerDriver() { + BrowserWebDriverContainer driverContainer = new BrowserWebDriverContainer<>() + .withCapabilities(new EdgeOptions()); + driverContainer.start(); + return new RemoteWebDriver(driverContainer.getSeleniumAddress(), new EdgeOptions()); + + } + @Override public EdgeOptions getOptions() { var edgeOptions = new EdgeOptions(); @@ -110,6 +137,11 @@ public WebDriver createLocalDriver() { return new SafariDriver(getOptions()); } + public WebDriver createTestContainerDriver() { + throw new IllegalArgumentException( + "Browser Safari not supported on TestContainers yet"); + + } @Override public SafariOptions getOptions() { @@ -134,4 +166,8 @@ public SafariOptions getOptions() { * @return a new AbstractDriverOptions instance based on the browser set */ public abstract AbstractDriverOptions getOptions(); + + + public abstract WebDriver createTestContainerDriver(); + } diff --git a/src/main/java/com/eliasnogueira/driver/TargetFactory.java b/src/main/java/com/eliasnogueira/driver/TargetFactory.java index 861a5d7..cfb8459 100644 --- a/src/main/java/com/eliasnogueira/driver/TargetFactory.java +++ b/src/main/java/com/eliasnogueira/driver/TargetFactory.java @@ -27,21 +27,14 @@ import com.eliasnogueira.enums.Target; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.openqa.selenium.Capabilities; import org.openqa.selenium.MutableCapabilities; import org.openqa.selenium.WebDriver; -import org.openqa.selenium.chrome.ChromeOptions; -import org.openqa.selenium.edge.EdgeOptions; -import org.openqa.selenium.firefox.FirefoxOptions; import org.openqa.selenium.remote.RemoteWebDriver; -import org.testcontainers.containers.BrowserWebDriverContainer; - import java.net.URL; - import static com.eliasnogueira.config.ConfigurationManager.configuration; import static com.eliasnogueira.driver.BrowserFactory.*; import static java.lang.String.format; -import static org.apache.commons.lang3.ObjectUtils.notEqual; + public class TargetFactory { @@ -54,8 +47,7 @@ public WebDriver createInstance(String browser) { case LOCAL -> valueOf(configuration().browser().toUpperCase()).createLocalDriver(); case LOCAL_SUITE -> valueOf(browser.toUpperCase()).createLocalDriver(); case SELENIUM_GRID -> createRemoteInstance(valueOf(browser.toUpperCase()).getOptions()); - case TESTCONTAINERS -> - createTestContainersInstance(valueOf(configuration().browser().toUpperCase()).getOptions()); + case TESTCONTAINERS -> valueOf(configuration().browser().toUpperCase()).createTestContainerDriver(); }; } @@ -75,25 +67,4 @@ private RemoteWebDriver createRemoteInstance(MutableCapabilities capability) { return remoteWebDriver; } - private RemoteWebDriver createTestContainersInstance(MutableCapabilities capabilities) { - String browser = capabilities.getBrowserName(); - BrowserWebDriverContainer driverContainer = null ; - if (browser.equalsIgnoreCase( CHROME.toString())) { - - driverContainer = new BrowserWebDriverContainer<>() - .withCapabilities(new ChromeOptions()); - } else if (browser.equalsIgnoreCase( FIREFOX.toString())) { - driverContainer = new BrowserWebDriverContainer<>() - .withCapabilities(new FirefoxOptions()); - } else if (browser.equalsIgnoreCase( "MicrosoftEdge")) { - driverContainer = new BrowserWebDriverContainer<>() - .withCapabilities(new EdgeOptions()); - }else { - throw new IllegalArgumentException( - format("Browser %s not supported for TestContainers", capabilities.getBrowserName())); - } - driverContainer.start(); - return new RemoteWebDriver(driverContainer.getSeleniumAddress(), capabilities); - - } } From c6d2714586623d388f700843c029217d81d4ea34 Mon Sep 17 00:00:00 2001 From: mdiwakar Date: Sun, 2 Jul 2023 10:33:30 -0700 Subject: [PATCH 109/191] 118: resetting to default --- src/test/resources/general.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/resources/general.properties b/src/test/resources/general.properties index de00661..69cf156 100644 --- a/src/test/resources/general.properties +++ b/src/test/resources/general.properties @@ -1,8 +1,8 @@ # target execution: local, selenium-grid or testcontainers -target = testcontainers +target = local # browser to use for local and testcontainers execution -browser = edge +browser = chrome # initial URL url.base = http://eliasnogueira.com/external/selenium-java-architecture/ From c1d2281fe9f5100d78feda6e698f1c760f8e28ba Mon Sep 17 00:00:00 2001 From: mdiwakar Date: Sun, 2 Jul 2023 10:37:40 -0700 Subject: [PATCH 110/191] 188: reverting to original changes --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index d6878eb..259fa12 100644 --- a/pom.xml +++ b/pom.xml @@ -9,8 +9,8 @@ 3.3.1 - scm:git@github.com:mdiwakar/selenium-java-lean-test-architecture.git - scm:git@github.com:mdiwakar/selenium-java-lean-test-architecture.git + scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git + scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git From db121984d82288fe420780ef26660eaeeed88281 Mon Sep 17 00:00:00 2001 From: mdiwakar Date: Sun, 2 Jul 2023 20:34:05 -0700 Subject: [PATCH 111/191] 188: adding relevant dependencies --- src/main/java/com/eliasnogueira/driver/TargetFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eliasnogueira/driver/TargetFactory.java b/src/main/java/com/eliasnogueira/driver/TargetFactory.java index cfb8459..5174c2c 100644 --- a/src/main/java/com/eliasnogueira/driver/TargetFactory.java +++ b/src/main/java/com/eliasnogueira/driver/TargetFactory.java @@ -32,7 +32,7 @@ import org.openqa.selenium.remote.RemoteWebDriver; import java.net.URL; import static com.eliasnogueira.config.ConfigurationManager.configuration; -import static com.eliasnogueira.driver.BrowserFactory.*; +import static com.eliasnogueira.driver.BrowserFactory.valueOf; import static java.lang.String.format; From a1c7068a8046b454e50889443eb540de1c0fc0ff Mon Sep 17 00:00:00 2001 From: mdiwakar Date: Mon, 3 Jul 2023 16:32:17 -0700 Subject: [PATCH 112/191] 188: Update documetation for test container support on Mac M1/M2 chip --- README.MD | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.MD b/README.MD index b1d95ae..8fccd25 100644 --- a/README.MD +++ b/README.MD @@ -154,13 +154,14 @@ to run the parallel tests using this example. #### BrowserFactory class This Factory class is a Java enum that has all implemented browsers to use during the test execution. -Each browser is an `enum`, and each enum implements three methods: +Each browser is an `enum`, and each enum implements four methods: * `createLocalDriver()`: creates the browser instance for the local execution. The browser driver is automatically managed by the WebDriverManager library * `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. You can see that the `createLocalDriver()` method use the `getOptions()` to get specific browser configurations, as starting the browser maximized and others. @@ -243,10 +244,13 @@ This means that Docker Selenium will start a container test for a targeting brow Please note that you need to do the following actions before running it in parallel: * Docker installed -* Pull the images for Chrome and Firefox - Optional +* 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 + * 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` From 9e7e370bcb5fbb591de878aa7aa873794f2a9828 Mon Sep 17 00:00:00 2001 From: mdiwakar Date: Tue, 4 Jul 2023 15:38:50 -0700 Subject: [PATCH 113/191] 188: removed whitelines --- .../eliasnogueira/driver/BrowserFactory.java | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java index 450c0d4..c71277f 100644 --- a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java +++ b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java @@ -38,8 +38,6 @@ import org.openqa.selenium.safari.SafariDriver; import org.openqa.selenium.safari.SafariOptions; import org.testcontainers.containers.BrowserWebDriverContainer; - - import static com.eliasnogueira.config.ConfigurationManager.configuration; import static com.eliasnogueira.data.changeless.BrowserData.CHROME_HEADLESS; import static com.eliasnogueira.data.changeless.BrowserData.DISABLE_INFOBARS; @@ -65,8 +63,6 @@ public WebDriver createTestContainerDriver() { .withCapabilities(new ChromeOptions()); driverContainer.start(); return new RemoteWebDriver(driverContainer.getSeleniumAddress(), new ChromeOptions()); - - } @Override public ChromeOptions getOptions() { @@ -75,16 +71,13 @@ public ChromeOptions getOptions() { chromeOptions.addArguments(DISABLE_INFOBARS); chromeOptions.addArguments(DISABLE_NOTIFICATIONS); chromeOptions.addArguments(REMOTE_ALLOW_ORIGINS); - if (configuration().headless()) chromeOptions.addArguments(CHROME_HEADLESS); - return chromeOptions; } }, FIREFOX { @Override public WebDriver createLocalDriver() { WebDriverManager.firefoxdriver().setup(); - return new FirefoxDriver(getOptions()); } @Override @@ -93,64 +86,51 @@ public WebDriver createTestContainerDriver() { .withCapabilities(new FirefoxOptions()); driverContainer.start(); return new RemoteWebDriver(driverContainer.getSeleniumAddress(), new FirefoxOptions()); - - } @Override public FirefoxOptions getOptions() { var firefoxOptions = new FirefoxOptions(); firefoxOptions.addArguments(START_MAXIMIZED); - if (configuration().headless()) firefoxOptions.addArguments(GENERIC_HEADLESS); - return firefoxOptions; } }, EDGE { @Override public WebDriver createLocalDriver() { WebDriverManager.edgedriver().setup(); - return new EdgeDriver(getOptions()); } - public WebDriver createTestContainerDriver() { BrowserWebDriverContainer driverContainer = new BrowserWebDriverContainer<>() .withCapabilities(new EdgeOptions()); driverContainer.start(); return new RemoteWebDriver(driverContainer.getSeleniumAddress(), new EdgeOptions()); - } @Override public EdgeOptions getOptions() { var edgeOptions = new EdgeOptions(); edgeOptions.addArguments(START_MAXIMIZED); - if (configuration().headless()) edgeOptions.addArguments(GENERIC_HEADLESS); - return edgeOptions; } }, SAFARI { @Override public WebDriver createLocalDriver() { WebDriverManager.safaridriver().setup(); - return new SafariDriver(getOptions()); } public WebDriver createTestContainerDriver() { throw new IllegalArgumentException( "Browser Safari not supported on TestContainers yet"); - } @Override public SafariOptions getOptions() { var safariOptions = new SafariOptions(); safariOptions.setAutomaticInspection(false); - if (TRUE.equals(configuration().headless())) throw new HeadlessNotSupportedException(safariOptions.getBrowserName()); - return safariOptions; } }; From e56006a938860f2fdb81151f64c85d5271ec01df Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Wed, 5 Jul 2023 19:09:15 +0200 Subject: [PATCH 114/191] lirbaries update --- pom.xml | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 8206c08..3e7f851 100644 --- a/pom.xml +++ b/pom.xml @@ -6,42 +6,43 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.3.1 + 3.3.2 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git - scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git + scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git + 17 UTF-8 UTF-8 - 3.0.0-M7 - 3.10.1 + 3.1.2 + 3.11.0 - 1.9.9.1 - 4.9.0 - 7.7.1 + 1.9.19 + 4.10.0 + 7.8.0 3.24.2 - 1.9.0 + 2.0.1 2.20.0 - 5.3.2 + 5.4.0 1.0.12 - 2.22.0 - 2.11.2 + 2.23.0 + 2.12.0 1.0.0 https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline - 1.18.0 + 1.18.3 3.6.3 2.0 2.11.0 4.13.2 - 2.15.0 + 2.15.2 1.70 local From ca756ab5c45210e055b345f3ebd5f1a3194dfdc2 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Wed, 5 Jul 2023 19:24:55 +0200 Subject: [PATCH 115/191] code format changes --- pom.xml | 2 +- .../eliasnogueira/driver/BrowserFactory.java | 64 +++++++++++-------- .../eliasnogueira/driver/TargetFactory.java | 4 +- 3 files changed, 42 insertions(+), 28 deletions(-) diff --git a/pom.xml b/pom.xml index 3e7f851..674c8ae 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.3.2 + 3.3.3 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git diff --git a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java index c71277f..656a32d 100644 --- a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java +++ b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java @@ -38,16 +38,11 @@ import org.openqa.selenium.safari.SafariDriver; import org.openqa.selenium.safari.SafariOptions; import org.testcontainers.containers.BrowserWebDriverContainer; + import static com.eliasnogueira.config.ConfigurationManager.configuration; -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 com.eliasnogueira.data.changeless.BrowserData.*; import static java.lang.Boolean.TRUE; - public enum BrowserFactory { CHROME { @@ -57,13 +52,15 @@ public WebDriver createLocalDriver() { return new ChromeDriver(getOptions()); } + @Override public WebDriver createTestContainerDriver() { - BrowserWebDriverContainer driverContainer = new BrowserWebDriverContainer<>() - .withCapabilities(new ChromeOptions()); - driverContainer.start(); - return new RemoteWebDriver(driverContainer.getSeleniumAddress(), new ChromeOptions()); + BrowserWebDriverContainer driverContainer = new BrowserWebDriverContainer<>().withCapabilities(new ChromeOptions()); + driverContainer.start(); + + return new RemoteWebDriver(driverContainer.getSeleniumAddress(), new ChromeOptions()); } + @Override public ChromeOptions getOptions() { var chromeOptions = new ChromeOptions(); @@ -71,71 +68,85 @@ public ChromeOptions getOptions() { chromeOptions.addArguments(DISABLE_INFOBARS); chromeOptions.addArguments(DISABLE_NOTIFICATIONS); chromeOptions.addArguments(REMOTE_ALLOW_ORIGINS); + if (configuration().headless()) chromeOptions.addArguments(CHROME_HEADLESS); + return chromeOptions; } }, FIREFOX { @Override public WebDriver createLocalDriver() { WebDriverManager.firefoxdriver().setup(); + return new FirefoxDriver(getOptions()); } + @Override public WebDriver createTestContainerDriver() { - BrowserWebDriverContainer driverContainer = new BrowserWebDriverContainer<>() - .withCapabilities(new FirefoxOptions()); - driverContainer.start(); - return new RemoteWebDriver(driverContainer.getSeleniumAddress(), new FirefoxOptions()); + BrowserWebDriverContainer driverContainer = new BrowserWebDriverContainer<>().withCapabilities(new FirefoxOptions()); + driverContainer.start(); + + return new RemoteWebDriver(driverContainer.getSeleniumAddress(), new FirefoxOptions()); } - @Override + + @Override public FirefoxOptions getOptions() { var firefoxOptions = new FirefoxOptions(); firefoxOptions.addArguments(START_MAXIMIZED); + if (configuration().headless()) firefoxOptions.addArguments(GENERIC_HEADLESS); + return firefoxOptions; } }, EDGE { @Override public WebDriver createLocalDriver() { WebDriverManager.edgedriver().setup(); + return new EdgeDriver(getOptions()); } + public WebDriver createTestContainerDriver() { - BrowserWebDriverContainer driverContainer = new BrowserWebDriverContainer<>() - .withCapabilities(new EdgeOptions()); - driverContainer.start(); - return new RemoteWebDriver(driverContainer.getSeleniumAddress(), new EdgeOptions()); + BrowserWebDriverContainer driverContainer = new BrowserWebDriverContainer<>().withCapabilities(new EdgeOptions()); + driverContainer.start(); + + return new RemoteWebDriver(driverContainer.getSeleniumAddress(), new EdgeOptions()); } @Override public EdgeOptions getOptions() { var edgeOptions = new EdgeOptions(); edgeOptions.addArguments(START_MAXIMIZED); + if (configuration().headless()) edgeOptions.addArguments(GENERIC_HEADLESS); + return edgeOptions; } }, SAFARI { @Override public WebDriver createLocalDriver() { WebDriverManager.safaridriver().setup(); + return new SafariDriver(getOptions()); } + public WebDriver createTestContainerDriver() { - throw new IllegalArgumentException( - "Browser Safari not supported on TestContainers yet"); + throw new IllegalArgumentException("Browser Safari not supported on TestContainers yet"); } @Override public SafariOptions getOptions() { var safariOptions = new SafariOptions(); safariOptions.setAutomaticInspection(false); + if (TRUE.equals(configuration().headless())) throw new HeadlessNotSupportedException(safariOptions.getBrowserName()); + return safariOptions; } }; - /**n + /** * Used to run local tests where the WebDriverManager will take care of the driver * * @return a new WebDriver instance based on the browser set @@ -147,7 +158,10 @@ public SafariOptions getOptions() { */ public abstract AbstractDriverOptions getOptions(); - + /** + * Used to run the remote test execution using Testcontainers + * + * @return a new WebDriver instance based on the browser set + */ public abstract WebDriver createTestContainerDriver(); - } diff --git a/src/main/java/com/eliasnogueira/driver/TargetFactory.java b/src/main/java/com/eliasnogueira/driver/TargetFactory.java index 5174c2c..359aa8c 100644 --- a/src/main/java/com/eliasnogueira/driver/TargetFactory.java +++ b/src/main/java/com/eliasnogueira/driver/TargetFactory.java @@ -30,12 +30,13 @@ import org.openqa.selenium.MutableCapabilities; import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.RemoteWebDriver; + import java.net.URL; + import static com.eliasnogueira.config.ConfigurationManager.configuration; import static com.eliasnogueira.driver.BrowserFactory.valueOf; import static java.lang.String.format; - public class TargetFactory { private static final Logger logger = LogManager.getLogger(TargetFactory.class); @@ -66,5 +67,4 @@ private RemoteWebDriver createRemoteInstance(MutableCapabilities capability) { return remoteWebDriver; } - } From 9146d1aee07a7c2aab268730b480074897d602ce Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Mon, 21 Aug 2023 22:33:05 +0200 Subject: [PATCH 116/191] remove parallelism --- src/test/resources/suites/local.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/suites/local.xml b/src/test/resources/suites/local.xml index bce93a4..089ee73 100644 --- a/src/test/resources/suites/local.xml +++ b/src/test/resources/suites/local.xml @@ -1,5 +1,5 @@ - + From 90a7a3a78e73f75973a4bf521d4efc780de9a4d1 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Mon, 21 Aug 2023 22:33:14 +0200 Subject: [PATCH 117/191] library updates --- pom.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 674c8ae..bcc11fe 100644 --- a/pom.xml +++ b/pom.xml @@ -21,13 +21,13 @@ 3.1.2 3.11.0 - 1.9.19 - 4.10.0 + 1.9.20 + 4.11.0 7.8.0 3.24.2 2.0.1 2.20.0 - 5.4.0 + 5.4.1 1.0.12 2.23.0 2.12.0 @@ -35,11 +35,11 @@ https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline - 1.18.3 + 1.19.0 3.6.3 - 2.0 + 2.1 2.11.0 4.13.2 2.15.2 From fd266008dfd02554eaf71475ed854321b9aa4a62 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Mon, 21 Aug 2023 22:33:28 +0200 Subject: [PATCH 118/191] added examples to execute tests in the command line --- README.MD | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/README.MD b/README.MD index 8fccd25..653ebae 100644 --- a/README.MD +++ b/README.MD @@ -130,6 +130,11 @@ When the `target` is `testcontainers` the `TargetFactory` uses the `createTestCo the container based on the browser set in the `browser` property. Currently, Testcontainers only supports Chrome and Firefox. +Example +```shell + mvn test -Pweb-execution -Dtarget=testcontainers -Dbrowser=chrome +``` + #### Remote execution ##### Selenium Grid @@ -219,7 +224,7 @@ 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 `parallel.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: @@ -250,10 +255,14 @@ Please note that you need to do the following actions before running it in paral * `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 From 1995ec95b83763667793ae85caee598077b57e24 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sun, 1 Oct 2023 21:42:24 +0200 Subject: [PATCH 119/191] library updates --- pom.xml | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/pom.xml b/pom.xml index bcc11fe..bad50d6 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.3.3 + 3.3.4 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -21,15 +21,15 @@ 3.1.2 3.11.0 - 1.9.20 - 4.11.0 + 1.9.20.1 + 4.13.0 7.8.0 3.24.2 2.0.1 2.20.0 - 5.4.1 + 5.5.3 1.0.12 - 2.23.0 + 2.24.0 2.12.0 1.0.0 @@ -38,12 +38,8 @@ 1.19.0 - 3.6.3 - 2.1 - 2.11.0 - 4.13.2 2.15.2 - 1.70 + 2.14.0 local @@ -157,20 +153,7 @@ commons-io commons-io - 2.11.0 - - - - org.bouncycastle - bcprov-jdk15on - ${bcprov-jdk15on.version} - - - - - org.yaml - snakeyaml - ${snakeyaml.version} + ${commons-io.version} From 0c992dc5954954141a46112518bd6301b4033ee2 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Mon, 6 Nov 2023 20:07:51 +0100 Subject: [PATCH 120/191] library updates --- pom.xml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index bcc11fe..61d6732 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.3.3 + 3.3.4 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -15,31 +15,31 @@ - 17 + 21 UTF-8 UTF-8 - 3.1.2 + 3.2.1 3.11.0 - 1.9.20 - 4.11.0 + 1.9.20.1 + 4.13.0 7.8.0 3.24.2 - 2.0.1 + 2.0.2 2.20.0 - 5.4.1 + 5.6.1 1.0.12 - 2.23.0 + 2.24.0 2.12.0 1.0.0 https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline - 1.19.0 + 1.19.1 3.6.3 - 2.1 + 2.2 2.11.0 4.13.2 2.15.2 From 9e29299861b2b195eeca84596881b08ad2e6332f Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Mon, 6 Nov 2023 20:08:04 +0100 Subject: [PATCH 121/191] java 21 update --- README.MD | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.MD b/README.MD index 653ebae..e26a83c 100644 --- a/README.MD +++ b/README.MD @@ -35,7 +35,7 @@ due to a conflict with the guava version of Selenium 4 This project uses the following languages and frameworks: -* [Java 17](https://openjdk.java.net/projects/jdk/17/) as the programming language +* [Java 21](https://openjdk.java.net/projects/jdk/21/) as the programming language * [TestNG](https://testng.org/doc/) as the UnitTest framework to support the test creation * [Selenium WebDriver](https://www.selenium.dev/) as the web browser automation framework using the Java binding * [AssertJ](https://joel-costigliola.github.io/assertj/) as the fluent assertion library @@ -132,7 +132,7 @@ Firefox. Example ```shell - mvn test -Pweb-execution -Dtarget=testcontainers -Dbrowser=chrome +mvn test -Pweb-execution -Dtarget=testcontainers -Dbrowser=chrome ``` #### Remote execution @@ -346,7 +346,7 @@ To do this you need: * Use `-Dsuite=suite_name` to call the suite ````bash -mvn test -Pweb-execution -Dsuite=parallel -Dtestng.dtd.http=true +mvn test -Pweb-execution -Dsuite=parallel ```` ### Pipeline as a code @@ -355,4 +355,4 @@ The two files of the pipeline as a code are inside `pipeline_as_code` folder. * GitHub Actions to use it inside the GitHub located at `.github\workflows` * Jenkins: `Jenkinsfile` to be used on a Jenkins pipeline located at `pipeline_as_code` -* GitLab CI: `.gitlab-ci.yml` to be used on a GitLab CI `pipeline_as_code` \ No newline at end of file +* GitLab CI: `.gitlab-ci.yml` to be used on a GitLab CI `pipeline_as_code` From 9068783550a2ce3c879be9ff05ab725d4304eb36 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Mon, 6 Nov 2023 20:08:07 +0100 Subject: [PATCH 122/191] java 21 update --- .github/workflows/test-execution.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index fd99162..ce18c2b 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -14,11 +14,11 @@ jobs: image: selenium/standalone-chrome options: --health-cmd '/opt/bin/check-grid.sh' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK uses: actions/setup-java@v3 with: - java-version: 17 + java-version: 21 distribution: adopt - name: Cache Maven packages From 940ddcc55c89e2637ffdc4e8640c83ad97d91cf8 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Mon, 6 Nov 2023 20:10:27 +0100 Subject: [PATCH 123/191] library update --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 5877ace..4ebd7fe 100644 --- a/pom.xml +++ b/pom.xml @@ -26,8 +26,8 @@ 7.8.0 3.24.2 2.0.1 - 2.20.0 - 5.4.1 + 2.21.1 + 5.6.1 1.0.12 2.23.0 2.12.0 @@ -40,9 +40,9 @@ 3.6.3 2.1 - 2.11.0 + 2.15.0 4.13.2 - 2.15.2 + 2.15.3 1.70 local From 40c6c7987b31d52166a6918bfb0c33ece1faefd9 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Mon, 13 Nov 2023 20:45:55 +0100 Subject: [PATCH 124/191] changed the locale approach in Java 21 --- .../java/com/eliasnogueira/data/dynamic/BookingDataFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java b/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java index d98633c..644b3c3 100644 --- a/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java +++ b/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java @@ -36,7 +36,7 @@ public final class BookingDataFactory { - private static final Faker faker = new Faker(new Locale(configuration().faker())); + private static final Faker faker = new Faker(new Locale.Builder().setLanguageTag(configuration().faker()).build()); private static final Logger logger = LogManager.getLogger(BookingDataFactory.class); private BookingDataFactory() { From 47445912dd76e1ac5acade42eee9ef50f10abaec Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Mon, 13 Nov 2023 20:46:18 +0100 Subject: [PATCH 125/191] changed usage of URI --- src/main/java/com/eliasnogueira/driver/TargetFactory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eliasnogueira/driver/TargetFactory.java b/src/main/java/com/eliasnogueira/driver/TargetFactory.java index 359aa8c..434c1a2 100644 --- a/src/main/java/com/eliasnogueira/driver/TargetFactory.java +++ b/src/main/java/com/eliasnogueira/driver/TargetFactory.java @@ -31,7 +31,7 @@ import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.RemoteWebDriver; -import java.net.URL; +import java.net.URI; import static com.eliasnogueira.config.ConfigurationManager.configuration; import static com.eliasnogueira.driver.BrowserFactory.valueOf; @@ -57,7 +57,7 @@ private RemoteWebDriver createRemoteInstance(MutableCapabilities capability) { try { String gridURL = format("http://%s:%s", configuration().gridUrl(), configuration().gridPort()); - remoteWebDriver = new RemoteWebDriver(new URL(gridURL), capability); + remoteWebDriver = new RemoteWebDriver(URI.create(gridURL).toURL(), capability); } catch (java.net.MalformedURLException e) { logger.error("Grid URL is invalid or Grid is not available"); logger.error(format("Browser: %s", capability.getBrowserName()), e); From 6248a80262615496f59044530aa75bd65c9a1f7e Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Mon, 13 Nov 2023 20:46:24 +0100 Subject: [PATCH 126/191] library update --- pom.xml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 4ebd7fe..3536fb1 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.3.4 + 3.3.5 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -15,31 +15,31 @@ - 17 + 21 UTF-8 UTF-8 - 3.1.2 + 3.2.2 3.11.0 - 1.9.20 - 4.11.0 + 1.9.20.1 + 4.13.0 7.8.0 3.24.2 - 2.0.1 + 2.0.2 2.21.1 - 5.6.1 + 5.6.2 1.0.12 - 2.23.0 + 2.24.0 2.12.0 1.0.0 https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline - 1.19.0 + 1.19.1 3.6.3 - 2.1 + 2.2 2.15.0 4.13.2 2.15.3 From 86ea62da08d00152e00791bc69c1eba8a753f436 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sun, 26 Nov 2023 20:00:56 +0100 Subject: [PATCH 127/191] library update --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 3536fb1..da4451d 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.3.5 + 3.3.6 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -21,7 +21,7 @@ 3.2.2 3.11.0 - 1.9.20.1 + 1.9.21.M1 4.13.0 7.8.0 3.24.2 @@ -35,14 +35,14 @@ https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline - 1.19.1 + 1.19.3 3.6.3 2.2 2.15.0 4.13.2 - 2.15.3 + 2.16.0 1.70 local From 3c788d8d706b0ca995f7a5d76a7a47393c5154ca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 30 Nov 2023 04:19:20 +0000 Subject: [PATCH 128/191] Bump commons-io:commons-io from 2.11.0 to 2.15.1 Bumps commons-io:commons-io from 2.11.0 to 2.15.1. --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index da4451d..97fb6f5 100644 --- a/pom.xml +++ b/pom.xml @@ -157,7 +157,7 @@ commons-io commons-io - 2.11.0 + 2.15.1 From dc44e5b9e48c8447156fda57572f57c299a71572 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Dec 2023 04:45:44 +0000 Subject: [PATCH 129/191] Bump allure.version from 2.24.0 to 2.25.0 Bumps `allure.version` from 2.24.0 to 2.25.0. Updates `io.qameta.allure:allure-testng` from 2.24.0 to 2.25.0 - [Release notes](https://github.com/allure-framework/allure-java/releases) - [Commits](https://github.com/allure-framework/allure-java/compare/2.24.0...2.25.0) Updates `io.qameta.allure:allure-attachments` from 2.24.0 to 2.25.0 - [Release notes](https://github.com/allure-framework/allure-java/releases) - [Commits](https://github.com/allure-framework/allure-java/compare/2.24.0...2.25.0) --- updated-dependencies: - dependency-name: io.qameta.allure:allure-testng dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: io.qameta.allure:allure-attachments dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index da4451d..82a4a56 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ 2.21.1 5.6.2 1.0.12 - 2.24.0 + 2.25.0 2.12.0 1.0.0 From 51a71e41f4b0d88186a6fd17c1957d51ef34a807 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 04:57:42 +0000 Subject: [PATCH 130/191] Bump org.aspectj:aspectjweaver from 1.9.21.M1 to 1.9.21 Bumps [org.aspectj:aspectjweaver](https://github.com/eclipse/org.aspectj) from 1.9.21.M1 to 1.9.21. - [Release notes](https://github.com/eclipse/org.aspectj/releases) - [Commits](https://github.com/eclipse/org.aspectj/commits) --- updated-dependencies: - dependency-name: org.aspectj:aspectjweaver dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cf846ec..07b1f3c 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ 3.2.2 3.11.0 - 1.9.21.M1 + 1.9.21 4.13.0 7.8.0 3.24.2 From 831d04ae64a572bbe08b4aa62e6290614eea5623 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Dec 2023 04:31:36 +0000 Subject: [PATCH 131/191] Bump org.apache.maven.plugins:maven-surefire-plugin from 3.2.2 to 3.2.3 Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.2 to 3.2.3. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.2...surefire-3.2.3) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 07b1f3c..50db73b 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ 21 UTF-8 UTF-8 - 3.2.2 + 3.2.3 3.11.0 1.9.21 From 547956c24c20be16e71f28661f17393962a95f63 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sun, 7 Jan 2024 23:03:45 +0100 Subject: [PATCH 132/191] removal of service --- .github/workflows/test-execution.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index ce18c2b..fbe9763 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -8,18 +8,15 @@ on: - main jobs: local-test: - runs-on: ubuntu-latest - services: - chrome: - image: selenium/standalone-chrome - options: --health-cmd '/opt/bin/check-grid.sh' + runs-on: macos-latest + steps: - uses: actions/checkout@v4 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: 21 - distribution: adopt + distribution: temurin - name: Cache Maven packages uses: actions/cache@v3 From 2ebf82754ed8a93bda2fc6649488a306b0e9ff34 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sun, 7 Jan 2024 23:03:52 +0100 Subject: [PATCH 133/191] library updates --- pom.xml | 46 +++++++++++++--------------------------------- 1 file changed, 13 insertions(+), 33 deletions(-) diff --git a/pom.xml b/pom.xml index 50db73b..4d91318 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.3.6 + 3.3.7 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -19,15 +19,15 @@ UTF-8 UTF-8 3.2.3 - 3.11.0 + 3.12.1 1.9.21 4.13.0 - 7.8.0 - 3.24.2 - 2.0.2 + 7.9.0 + 3.25.1 + 2.1.0 2.21.1 - 5.6.2 + 5.6.3 1.0.12 2.25.0 2.12.0 @@ -38,12 +38,7 @@ 1.19.3 - 3.6.3 - 2.2 - 2.15.0 - 4.13.2 - 2.16.0 - 1.70 + 2.16.1 local @@ -113,6 +108,12 @@ io.github.bonigarcia webdrivermanager ${webdrivermanager.version} + + + com.fasterxml.jackson.core + jackson-databind + + @@ -146,33 +147,12 @@ - - com.fasterxml.jackson.core jackson-databind ${jackson-databind.version} - - commons-io - commons-io - 2.15.1 - - - - org.bouncycastle - bcprov-jdk15on - ${bcprov-jdk15on.version} - - - - - org.yaml - snakeyaml - ${snakeyaml.version} - - From ee30a4429f2d47e0fa7ab8890bb01afbc22fdfbe Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sun, 7 Jan 2024 23:06:03 +0100 Subject: [PATCH 134/191] library updates --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4d91318..08cb301 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ 7.9.0 3.25.1 2.1.0 - 2.21.1 + 2.22.1 5.6.3 1.0.12 2.25.0 From 3d4f90270be6b86c4fe722a75fdd408d983b2520 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sat, 13 Jan 2024 14:44:34 +0100 Subject: [PATCH 135/191] removed the usage of WebDriverManager in favour of Selenium Manager --- src/main/java/com/eliasnogueira/driver/BrowserFactory.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java index 656a32d..35816b3 100644 --- a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java +++ b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java @@ -48,8 +48,6 @@ public enum BrowserFactory { CHROME { @Override public WebDriver createLocalDriver() { - WebDriverManager.chromedriver().setup(); - return new ChromeDriver(getOptions()); } @@ -76,8 +74,6 @@ public ChromeOptions getOptions() { }, FIREFOX { @Override public WebDriver createLocalDriver() { - WebDriverManager.firefoxdriver().setup(); - return new FirefoxDriver(getOptions()); } @@ -101,8 +97,6 @@ public FirefoxOptions getOptions() { }, EDGE { @Override public WebDriver createLocalDriver() { - WebDriverManager.edgedriver().setup(); - return new EdgeDriver(getOptions()); } From 82f7cf4ed5ac1ee3906e7af0482b296dc23fc887 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sat, 13 Jan 2024 14:44:51 +0100 Subject: [PATCH 136/191] updated selenium/video to latest --- grid/config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grid/config.toml b/grid/config.toml index 825693d..b304a88 100644 --- a/grid/config.toml +++ b/grid/config.toml @@ -13,7 +13,7 @@ configs = [ # socat -4 TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock url = "http://host.docker.internal:2375/" # Docker image used for video recording -video-image = "selenium/video:ffmpeg-4.3.1-20220628" +video-image = "selenium/video:latest" # Uncomment the following section if you are running the node on a separate VM # Fill out the placeholders with appropriate values From cf0e4148b2aea3200fb80ec2ac4bf75f9cc4677b Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sat, 13 Jan 2024 14:45:00 +0100 Subject: [PATCH 137/191] library updates --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 08cb301..b08e8c4 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.3.7 + 3.3.8 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -18,7 +18,7 @@ 21 UTF-8 UTF-8 - 3.2.3 + 3.2.5 3.12.1 1.9.21 From 55dbda96fe23c39c0671ca3ae30b6ed4abf6249e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Jan 2024 04:38:23 +0000 Subject: [PATCH 138/191] Bump org.assertj:assertj-core from 3.25.1 to 3.25.2 Bumps [org.assertj:assertj-core](https://github.com/assertj/assertj) from 3.25.1 to 3.25.2. - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](https://github.com/assertj/assertj/compare/assertj-build-3.25.1...assertj-build-3.25.2) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b08e8c4..1d7fe65 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ 1.9.21 4.13.0 7.9.0 - 3.25.1 + 3.25.2 2.1.0 2.22.1 5.6.3 From aafea6cb6d69fe5590f40c8f3ddc512f5060ebf9 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sat, 27 Jan 2024 12:17:17 +0100 Subject: [PATCH 139/191] added https protocol --- src/test/resources/general.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/general.properties b/src/test/resources/general.properties index 69cf156..15bb713 100644 --- a/src/test/resources/general.properties +++ b/src/test/resources/general.properties @@ -5,7 +5,7 @@ target = local browser = chrome # initial URL -url.base = http://eliasnogueira.com/external/selenium-java-architecture/ +url.base = https://eliasnogueira.com/external/selenium-java-architecture/ # global test timeout timeout = 3 From 9ed292321f23489bfe957bac6ecd39023cc2301b Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sat, 27 Jan 2024 12:17:34 +0100 Subject: [PATCH 140/191] removal of local.properties --- src/main/java/com/eliasnogueira/config/Configuration.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/eliasnogueira/config/Configuration.java b/src/main/java/com/eliasnogueira/config/Configuration.java index 4322f53..dda4233 100644 --- a/src/main/java/com/eliasnogueira/config/Configuration.java +++ b/src/main/java/com/eliasnogueira/config/Configuration.java @@ -32,7 +32,6 @@ @Config.Sources({ "system:properties", "classpath:general.properties", - "classpath:local.properties", "classpath:selenium-grid.properties"}) public interface Configuration extends Config { From f7712a48b5eba6c8839adc8a168d88fae4f58c6f Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sat, 27 Jan 2024 13:37:43 +0100 Subject: [PATCH 141/191] added value check --- src/main/java/com/eliasnogueira/enums/Target.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/eliasnogueira/enums/Target.java b/src/main/java/com/eliasnogueira/enums/Target.java index 0b7618d..8f38068 100644 --- a/src/main/java/com/eliasnogueira/enums/Target.java +++ b/src/main/java/com/eliasnogueira/enums/Target.java @@ -33,7 +33,8 @@ public enum Target { - LOCAL("local"), LOCAL_SUITE("local-suite"), SELENIUM_GRID("selenium-grid"), TESTCONTAINERS("testcontainers"); + LOCAL("local"), LOCAL_SUITE("local-suite"), SELENIUM_GRID("selenium-grid"), + TESTCONTAINERS("testcontainers"); private final String value; private static final Map ENUM_MAP; @@ -43,12 +44,15 @@ public enum Target { } static { - Map map = stream(Target.values()).collect(toMap( - instance -> instance.value.toLowerCase(), instance -> instance, (a, b) -> b, ConcurrentHashMap::new)); + Map map = stream(Target.values()) + .collect(toMap(instance -> instance.value.toLowerCase(), instance -> instance, (a, b) -> b, ConcurrentHashMap::new)); ENUM_MAP = Collections.unmodifiableMap(map); } public static Target get(String value) { + if (!ENUM_MAP.containsKey(value.toLowerCase())) + throw new IllegalArgumentException(String.format("Value %s not valid. Use one of the TARGET enum values", value)); + return ENUM_MAP.get(value.toLowerCase()); } } From 147230466c5d38eb19123e8e880e0ade4b24b466 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sat, 27 Jan 2024 13:39:02 +0100 Subject: [PATCH 142/191] bump testcontainers --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b08e8c4..7efedd5 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline - 1.19.3 + 1.19.4 2.16.1 From f1fbe496abe18cb984308e040885a733cc45e565 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sat, 27 Jan 2024 13:40:26 +0100 Subject: [PATCH 143/191] bump project version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7efedd5..b1b35f3 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.3.8 + 3.3.9 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git From 740008ad387f08e8c251ee963c7ca1a49823861e Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sat, 27 Jan 2024 15:01:17 +0100 Subject: [PATCH 144/191] removal of webdrivermanager --- pom.xml | 25 +------------------ .../eliasnogueira/driver/BrowserFactory.java | 2 -- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/pom.xml b/pom.xml index b1b35f3..40fd31c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.3.9 + 3.3.10 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -27,7 +27,6 @@ 3.25.1 2.1.0 2.22.1 - 5.6.3 1.0.12 2.25.0 2.12.0 @@ -37,9 +36,6 @@ 1.19.4 - - 2.16.1 - local @@ -104,18 +100,6 @@ ${owner.version} - - io.github.bonigarcia - webdrivermanager - ${webdrivermanager.version} - - - com.fasterxml.jackson.core - jackson-databind - - - - io.qameta.allure allure-testng @@ -146,13 +130,6 @@ ${testcontainers.selenium.version} - - - com.fasterxml.jackson.core - jackson-databind - ${jackson-databind.version} - - diff --git a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java index 35816b3..dc15f4f 100644 --- a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java +++ b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java @@ -119,8 +119,6 @@ public EdgeOptions getOptions() { }, SAFARI { @Override public WebDriver createLocalDriver() { - WebDriverManager.safaridriver().setup(); - return new SafariDriver(getOptions()); } From 1dbf635e0548cff8747ea04e5e45f6e2a461a83e Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sat, 27 Jan 2024 15:01:47 +0100 Subject: [PATCH 145/191] removal of webdrivermanager --- src/main/java/com/eliasnogueira/driver/BrowserFactory.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java index dc15f4f..3bb5dd4 100644 --- a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java +++ b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java @@ -25,7 +25,6 @@ package com.eliasnogueira.driver; import com.eliasnogueira.exceptions.HeadlessNotSupportedException; -import io.github.bonigarcia.wdm.WebDriverManager; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; From a8ab6e58dc70617b275710806d0a7dceb5442ae7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 04:58:09 +0000 Subject: [PATCH 146/191] Bump org.assertj:assertj-core from 3.25.2 to 3.25.3 Bumps [org.assertj:assertj-core](https://github.com/assertj/assertj) from 3.25.2 to 3.25.3. - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](https://github.com/assertj/assertj/compare/assertj-build-3.25.2...assertj-build-3.25.3) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index deb661f..b4eb1cd 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ 1.9.21 4.13.0 7.9.0 - 3.25.2 + 3.25.3 2.1.0 2.22.1 1.0.12 From b4c5d7292491bdaea099afbec98d32334d3f0127 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 9 Feb 2024 04:27:30 +0000 Subject: [PATCH 147/191] Bump org.testcontainers:selenium from 1.19.4 to 1.19.5 Bumps [org.testcontainers:selenium](https://github.com/testcontainers/testcontainers-java) from 1.19.4 to 1.19.5. - [Release notes](https://github.com/testcontainers/testcontainers-java/releases) - [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md) - [Commits](https://github.com/testcontainers/testcontainers-java/compare/1.19.4...1.19.5) --- updated-dependencies: - dependency-name: org.testcontainers:selenium dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b4eb1cd..f745f73 100644 --- a/pom.xml +++ b/pom.xml @@ -34,7 +34,7 @@ https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline - 1.19.4 + 1.19.5 local From 1f570b537a6e93b24cda4c453ea14b5f321cf078 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Feb 2024 04:49:43 +0000 Subject: [PATCH 148/191] Bump org.aspectj:aspectjweaver from 1.9.21 to 1.9.21.1 Bumps [org.aspectj:aspectjweaver](https://github.com/eclipse/org.aspectj) from 1.9.21 to 1.9.21.1. - [Release notes](https://github.com/eclipse/org.aspectj/releases) - [Commits](https://github.com/eclipse/org.aspectj/commits) --- updated-dependencies: - dependency-name: org.aspectj:aspectjweaver dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f745f73..f77da83 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ 3.2.5 3.12.1 - 1.9.21 + 1.9.21.1 4.13.0 7.9.0 3.25.3 From 67ea7f4e9f9dcc688d337eb9cfaf343fbaad4457 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sun, 17 Mar 2024 13:31:50 +0100 Subject: [PATCH 149/191] library update and removal of selenium-http-jdk-client --- pom.xml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index 40fd31c..4c99496 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.3.10 + 3.3.11 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -21,12 +21,12 @@ 3.2.5 3.12.1 - 1.9.21 - 4.13.0 + 1.9.21.2 + 4.18.1 7.9.0 - 3.25.1 + 3.25.3 2.1.0 - 2.22.1 + 2.23.1 1.0.12 2.25.0 2.12.0 @@ -34,7 +34,7 @@ https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline - 1.19.4 + 1.19.7 local @@ -46,12 +46,6 @@ ${selenium.version} - - org.seleniumhq.selenium - selenium-http-jdk-client - ${selenium.version} - - org.testng testng From 0457f689706281b40f0cf3e89059a81892c58bce Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Wed, 20 Mar 2024 20:07:45 +0100 Subject: [PATCH 150/191] chore: library updates --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 4c99496..4332a2a 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.3.11 + 3.4.0 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -15,11 +15,11 @@ - 21 + 22 UTF-8 UTF-8 3.2.5 - 3.12.1 + 3.13.0 1.9.21.2 4.18.1 @@ -28,7 +28,7 @@ 2.1.0 2.23.1 1.0.12 - 2.25.0 + 2.26.0 2.12.0 1.0.0 From 3ceb24285570e0ddaed80985d49074138b8d0e4e Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Wed, 20 Mar 2024 20:07:57 +0100 Subject: [PATCH 151/191] chore: general refactor --- src/main/java/com/eliasnogueira/enums/Target.java | 2 +- .../eliasnogueira/page/booking/common/NavigationPage.java | 5 ----- src/test/java/com/eliasnogueira/BaseWeb.java | 1 - src/test/java/com/eliasnogueira/test/BookRoomWebTest.java | 2 +- 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/eliasnogueira/enums/Target.java b/src/main/java/com/eliasnogueira/enums/Target.java index 8f38068..d9dfa4e 100644 --- a/src/main/java/com/eliasnogueira/enums/Target.java +++ b/src/main/java/com/eliasnogueira/enums/Target.java @@ -45,7 +45,7 @@ public enum Target { static { Map map = stream(Target.values()) - .collect(toMap(instance -> instance.value.toLowerCase(), instance -> instance, (a, b) -> b, ConcurrentHashMap::new)); + .collect(toMap(instance -> instance.value.toLowerCase(), instance -> instance, (_, b) -> b, ConcurrentHashMap::new)); ENUM_MAP = Collections.unmodifiableMap(map); } diff --git a/src/main/java/com/eliasnogueira/page/booking/common/NavigationPage.java b/src/main/java/com/eliasnogueira/page/booking/common/NavigationPage.java index 46be648..ceafb1d 100644 --- a/src/main/java/com/eliasnogueira/page/booking/common/NavigationPage.java +++ b/src/main/java/com/eliasnogueira/page/booking/common/NavigationPage.java @@ -45,11 +45,6 @@ public void next() { next.click(); } - @Step - public void previous() { - previous.click(); - } - @Step public void finish() { finish.click(); diff --git a/src/test/java/com/eliasnogueira/BaseWeb.java b/src/test/java/com/eliasnogueira/BaseWeb.java index b7965de..678bc58 100644 --- a/src/test/java/com/eliasnogueira/BaseWeb.java +++ b/src/test/java/com/eliasnogueira/BaseWeb.java @@ -42,7 +42,6 @@ public abstract class BaseWeb { @BeforeSuite public void beforeSuite() { - System.setProperty("webdriver.http.factory", "jdk-http-client"); AllureManager.setAllureEnvironmentInformation(); } diff --git a/src/test/java/com/eliasnogueira/test/BookRoomWebTest.java b/src/test/java/com/eliasnogueira/test/BookRoomWebTest.java index 7471352..9e76a31 100644 --- a/src/test/java/com/eliasnogueira/test/BookRoomWebTest.java +++ b/src/test/java/com/eliasnogueira/test/BookRoomWebTest.java @@ -55,6 +55,6 @@ public void bookARoom() { detailPage.finish(); assertThat(detailPage.getAlertMessage()) - .isEqualTo("Your reservation has been made and we will contact you shortly"); + .isEqualTo("YYour reservation has been made and we will contact you shortly"); } } From 17123275ebf676ffe2cba152d7756162ec37b66f Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Wed, 20 Mar 2024 20:08:07 +0100 Subject: [PATCH 152/191] chore: java 22 adoption --- .github/workflows/test-execution.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index fbe9763..5ad73d9 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -15,8 +15,8 @@ jobs: - name: Set up JDK uses: actions/setup-java@v4 with: - java-version: 21 - distribution: temurin + java-version: 22 + distribution: oracle - name: Cache Maven packages uses: actions/cache@v3 From 6e67fc4010d5868600539923108bb8efdb36d54d Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Wed, 20 Mar 2024 20:09:02 +0100 Subject: [PATCH 153/191] chore: latest updates --- README.MD | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/README.MD b/README.MD index e26a83c..7a79ede 100644 --- a/README.MD +++ b/README.MD @@ -10,16 +10,7 @@ It has a complete solution to run tests in different ways: * local testing using the browser on your local machine * parallel (or single) testing using Selenium Docker * local testing using TestContainers -* Distributed execution using Selenium Grid - -## Important information - -### Know issues - -```shell -This current version has excluded the guava library from WebDriverManager and Allure Environment Writer -due to a conflict with the guava version of Selenium 4 -``` +* Distributed execution using Selenium Grid ## Examples @@ -35,7 +26,7 @@ due to a conflict with the guava version of Selenium 4 This project uses the following languages and frameworks: -* [Java 21](https://openjdk.java.net/projects/jdk/21/) as the programming language +* [Java 22](https://openjdk.java.net/projects/jdk/22/) as the programming language * [TestNG](https://testng.org/doc/) as the UnitTest framework to support the test creation * [Selenium WebDriver](https://www.selenium.dev/) as the web browser automation framework using the Java binding * [AssertJ](https://joel-costigliola.github.io/assertj/) as the fluent assertion library From aaee279ba711ecfd1e993757aabac51538b4c37d Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Wed, 20 Mar 2024 20:12:00 +0100 Subject: [PATCH 154/191] fix: changed intentional assertion failure --- src/test/java/com/eliasnogueira/test/BookRoomWebTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/eliasnogueira/test/BookRoomWebTest.java b/src/test/java/com/eliasnogueira/test/BookRoomWebTest.java index 9e76a31..7471352 100644 --- a/src/test/java/com/eliasnogueira/test/BookRoomWebTest.java +++ b/src/test/java/com/eliasnogueira/test/BookRoomWebTest.java @@ -55,6 +55,6 @@ public void bookARoom() { detailPage.finish(); assertThat(detailPage.getAlertMessage()) - .isEqualTo("YYour reservation has been made and we will contact you shortly"); + .isEqualTo("Your reservation has been made and we will contact you shortly"); } } From e73594521cc88e48d816128015be34d0ea3fdde4 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Thu, 28 Mar 2024 21:53:13 +0100 Subject: [PATCH 155/191] chore: library update --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 4332a2a..2f90717 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.4.0 + 3.4.1 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -21,8 +21,8 @@ 3.2.5 3.13.0 - 1.9.21.2 - 4.18.1 + 1.9.22 + 4.19.0 7.9.0 3.25.3 2.1.0 From c9d248c3e671bd655534cd537c6deded91a2215e Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Wed, 10 Apr 2024 22:44:01 +0200 Subject: [PATCH 156/191] chore: library update --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 2f90717..ffc9b46 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.4.1 + 3.4.2 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -22,13 +22,13 @@ 3.13.0 1.9.22 - 4.19.0 - 7.9.0 + 4.19.1 + 7.10.1 3.25.3 2.1.0 2.23.1 1.0.12 - 2.26.0 + 2.27.0 2.12.0 1.0.0 From b1d922b20b0a484eb06102ffe01fe6fcb408d480 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sat, 20 Apr 2024 17:07:39 +0200 Subject: [PATCH 157/191] chore: remove of TestNG listener --- .../java/com/eliasnogueira/TestListener.java | 79 ------------------- 1 file changed, 79 deletions(-) delete mode 100644 src/test/java/com/eliasnogueira/TestListener.java diff --git a/src/test/java/com/eliasnogueira/TestListener.java b/src/test/java/com/eliasnogueira/TestListener.java deleted file mode 100644 index a0fa483..0000000 --- a/src/test/java/com/eliasnogueira/TestListener.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2018 Elias Nogueira - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.eliasnogueira; - -import com.eliasnogueira.report.AllureManager; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.testng.ITestContext; -import org.testng.ITestListener; -import org.testng.ITestResult; - -public class TestListener implements ITestListener { - - private static final Logger logger = LogManager.getLogger(TestListener.class); - - @Override - public void onTestStart(ITestResult result) { - // empty - } - - @Override - public void onTestSuccess(ITestResult result) { - // empty - } - - @Override - public void onTestFailure(ITestResult result) { - failTest(result); - } - - @Override - public void onTestSkipped(ITestResult result) { - logger.error(result.getThrowable()); - } - - @Override - public void onTestFailedButWithinSuccessPercentage(ITestResult result) { - // empty - } - - @Override - public void onStart(ITestContext context) { - // empty - } - - @Override - public void onFinish(ITestContext context) { - // empty - } - - private void failTest(ITestResult iTestResult) { - logger.error(iTestResult.getTestClass().getName()); - logger.error(iTestResult.getThrowable()); - - AllureManager.takeScreenshotToAttachOnAllureReport(); - } -} From a2851a3f910f46195a11b9a190a23b0740915c66 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sat, 20 Apr 2024 17:08:08 +0200 Subject: [PATCH 158/191] feat: register Allure listener --- .../services/io.qameta.allure.listener.TestLifecycleListener | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/test/resources/META-INF/services/io.qameta.allure.listener.TestLifecycleListener diff --git a/src/test/resources/META-INF/services/io.qameta.allure.listener.TestLifecycleListener b/src/test/resources/META-INF/services/io.qameta.allure.listener.TestLifecycleListener new file mode 100644 index 0000000..dda40f5 --- /dev/null +++ b/src/test/resources/META-INF/services/io.qameta.allure.listener.TestLifecycleListener @@ -0,0 +1 @@ +com.eliasnogueira.report.AllureTestLifecycleListener From 5e7913aa0695f63d30f773bc85aaaef604e54105 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sat, 20 Apr 2024 17:08:20 +0200 Subject: [PATCH 159/191] chore: removal of custom test listener --- src/test/java/com/eliasnogueira/BaseWeb.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/java/com/eliasnogueira/BaseWeb.java b/src/test/java/com/eliasnogueira/BaseWeb.java index 678bc58..cd5c894 100644 --- a/src/test/java/com/eliasnogueira/BaseWeb.java +++ b/src/test/java/com/eliasnogueira/BaseWeb.java @@ -31,13 +31,11 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Listeners; import org.testng.annotations.Optional; import org.testng.annotations.Parameters; import static com.eliasnogueira.config.ConfigurationManager.configuration; -@Listeners({TestListener.class}) public abstract class BaseWeb { @BeforeSuite From b3695449724b3e45f1e9b931b0a3e0c05565ac9d Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sat, 20 Apr 2024 17:08:56 +0200 Subject: [PATCH 160/191] chore: removal of the attachment approach in favor of the Allure listener --- .../com/eliasnogueira/report/AllureManager.java | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/main/java/com/eliasnogueira/report/AllureManager.java b/src/main/java/com/eliasnogueira/report/AllureManager.java index 4fabc20..2180e2e 100644 --- a/src/main/java/com/eliasnogueira/report/AllureManager.java +++ b/src/main/java/com/eliasnogueira/report/AllureManager.java @@ -24,18 +24,14 @@ package com.eliasnogueira.report; -import com.eliasnogueira.driver.DriverManager; import com.eliasnogueira.enums.Target; import com.github.automatedowl.tools.AllureEnvironmentWriter; import com.google.common.collect.ImmutableMap; -import io.qameta.allure.Attachment; -import org.openqa.selenium.TakesScreenshot; import java.util.HashMap; import java.util.Map; import static com.eliasnogueira.config.ConfigurationManager.configuration; -import static org.openqa.selenium.OutputType.BYTES; public class AllureManager { @@ -59,14 +55,4 @@ public static void setAllureEnvironmentInformation() { AllureEnvironmentWriter.allureEnvironmentWriter(ImmutableMap.copyOf(basicInfo)); } - - @Attachment(value = "Failed test screenshot", type = "image/png") - public static byte[] takeScreenshotToAttachOnAllureReport() { - return ((TakesScreenshot) DriverManager.getDriver()).getScreenshotAs(BYTES); - } - - @Attachment(value = "Browser information", type = "text/plain") - public static String addBrowserInformationOnAllureReport() { - return DriverManager.getInfo(); - } } From 92d1d6d496eb05d8a3398a9092d2d53517d575bd Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sat, 20 Apr 2024 17:09:18 +0200 Subject: [PATCH 161/191] feat: custom Allure listener to take screenshot when test fails --- .../report/AllureTestLifecycleListener.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/main/java/com/eliasnogueira/report/AllureTestLifecycleListener.java diff --git a/src/main/java/com/eliasnogueira/report/AllureTestLifecycleListener.java b/src/main/java/com/eliasnogueira/report/AllureTestLifecycleListener.java new file mode 100644 index 0000000..4d09ef2 --- /dev/null +++ b/src/main/java/com/eliasnogueira/report/AllureTestLifecycleListener.java @@ -0,0 +1,56 @@ +/* + * MIT License + * + * Copyright (c) 2024 Elias Nogueira + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.eliasnogueira.report; + +import com.eliasnogueira.driver.DriverManager; +import io.qameta.allure.Attachment; +import io.qameta.allure.listener.TestLifecycleListener; +import io.qameta.allure.model.TestResult; +import org.openqa.selenium.OutputType; +import org.openqa.selenium.TakesScreenshot; +import org.openqa.selenium.WebDriver; + +import static io.qameta.allure.model.Status.BROKEN; +import static io.qameta.allure.model.Status.FAILED; + +/* + * Approach implemented using the https://github.com/biczomate/allure-testng7.5-attachment-example as reference + */ +public class AllureTestLifecycleListener implements TestLifecycleListener { + + public AllureTestLifecycleListener() { + } + + @Attachment(value = "Page Screenshot", type = "image/png") + public byte[] saveScreenshot(WebDriver driver) { + return ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES); + } + + @Override + public void beforeTestStop(TestResult result) { + if (FAILED == result.getStatus() || BROKEN == result.getStatus()) { + saveScreenshot(DriverManager.getDriver()); + } + } +} From 476781b441ae03d7dcb2847ac63eacca7b051e7f Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sat, 20 Apr 2024 17:09:41 +0200 Subject: [PATCH 162/191] chore: bump version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ffc9b46..267d68d 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.4.2 + 3.4.3 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git From c0a27645fc5f506a1c3d7f0bf78263c1ed68c654 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 24 Apr 2024 04:55:08 +0000 Subject: [PATCH 163/191] Bump net.datafaker:datafaker from 2.1.0 to 2.2.0 Bumps [net.datafaker:datafaker](https://github.com/datafaker-net/datafaker) from 2.1.0 to 2.2.0. - [Commits](https://github.com/datafaker-net/datafaker/compare/v2.1.0...v2.2.0) --- updated-dependencies: - dependency-name: net.datafaker:datafaker dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 267d68d..b4a3901 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ 4.19.1 7.10.1 3.25.3 - 2.1.0 + 2.2.0 2.23.1 1.0.12 2.27.0 From b54f413fe849b1cea0ce8c4d3dbc043a08e7f910 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Mon, 29 Apr 2024 09:27:41 +0000 Subject: [PATCH 164/191] fix: removed webdrivermanager references --- README.MD | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/README.MD b/README.MD index 7a79ede..083075d 100644 --- a/README.MD +++ b/README.MD @@ -33,9 +33,8 @@ This project uses the following languages and frameworks: * [Allure Report](https://docs.qameta.io/allure/) as the testing report strategy * [DataFaker](https://www.datafaker.net/) as the faker data generation strategy * [Log4J2](https://logging.apache.org/log4j/2.x/) as the logging management strategy -* [WebDriverManager](https://github.com/bonigarcia/webdrivermanager) as the Selenium binaries management * [Owner](http://owner.aeonbits.org/) to minimize the code to handle the properties file -* [TestContainers] (https://java.testcontainers.org/modules/webdriver_containers/) Webdriver Containers +* [TestContainers](https://java.testcontainers.org/modules/webdriver_containers/) Webdriver Containers ## Test architecture @@ -99,8 +98,6 @@ on `general.properties` file. Its usage is placed on the `BaseWeb` class before **This approach is automatically used when you run the test class in your IDE.** -This execution type uses [WebDriverManager](https://github.com/bonigarcia/webdrivermanager) class to instantiate the web -browsers. When the `target` is `local` the `createLocalDriver()` method is used from the `BrowserFactory` class to return the browser instance. @@ -108,8 +105,7 @@ The browser used in the test is placed on the `browser` property in the `general ##### Local Suite -This execution type also uses the [WebDriverManager](https://github.com/bonigarcia/webdrivermanager) to instantiate the -web browser. 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 From 165ebe913c2c66846367128b54da39dc975219a5 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Mon, 29 Apr 2024 09:27:58 +0000 Subject: [PATCH 165/191] chore: libraries update --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index b4a3901..aa2ff4a 100644 --- a/pom.xml +++ b/pom.xml @@ -22,10 +22,10 @@ 3.13.0 1.9.22 - 4.19.1 - 7.10.1 + 4.20.0 + 7.10.2 3.25.3 - 2.2.0 + 2.2.2 2.23.1 1.0.12 2.27.0 From 0aeed7155c8d70ff29b67994ba3fb1bd5f1fab53 Mon Sep 17 00:00:00 2001 From: Elias Nogueira Date: Mon, 29 Apr 2024 10:12:34 +0000 Subject: [PATCH 166/191] chore: bump version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index aa2ff4a..c48aeed 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.4.3 + 3.4.4 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git From d1888a352305beaef4827d5b2f48138ed8a597b6 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sun, 26 May 2024 19:02:24 +0200 Subject: [PATCH 167/191] chore: refactor --- grid/config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grid/config.toml b/grid/config.toml index b304a88..518c9d4 100644 --- a/grid/config.toml +++ b/grid/config.toml @@ -19,4 +19,4 @@ video-image = "selenium/video:latest" # Fill out the placeholders with appropriate values #[server] #host = -#port = \ No newline at end of file +#port = From f372c2f0f24a8731b820937f251655608ca1913f Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sun, 26 May 2024 19:02:30 +0200 Subject: [PATCH 168/191] chore: library updates --- pom.xml | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 267d68d..4293609 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.4.3 + 3.4.4 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -21,11 +21,11 @@ 3.2.5 3.13.0 - 1.9.22 - 4.19.1 - 7.10.1 - 3.25.3 - 2.1.0 + 1.9.22.1 + 4.21.0 + 7.10.2 + 3.26.0 + 2.2.2 2.23.1 1.0.12 2.27.0 @@ -34,7 +34,10 @@ https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline - 1.19.7 + 1.19.8 + + + 1.26.2 local @@ -122,6 +125,19 @@ org.testcontainers selenium ${testcontainers.selenium.version} + + + org.apache.commons + commons-compress + + + + + + + org.apache.commons + commons-compress + ${commons-compress.version} From 5a8f0d8685e2d412ba823a83567c12b0124ec16a Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sun, 26 May 2024 19:02:42 +0200 Subject: [PATCH 169/191] chore: bump action/cache --- .github/workflows/test-execution.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index 5ad73d9..24d764d 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -19,7 +19,7 @@ jobs: distribution: oracle - name: Cache Maven packages - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.m2/repository key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} @@ -27,7 +27,7 @@ jobs: ${{ runner.os }}-maven- - name: Build with Maven - run: mvn -B -q -DskipTests package --file pom.xml + run: mvn -B -q -DskipTests package - name: Run local tests run: mvn -B -q test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome From f73e058e4009107b98ab2551f99fc0194d8f2cd6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 04:31:57 +0000 Subject: [PATCH 170/191] Bump org.apache.maven.plugins:maven-surefire-plugin from 3.2.5 to 3.3.0 Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.5 to 3.3.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.5...surefire-3.3.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4293609..2fff88d 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ 22 UTF-8 UTF-8 - 3.2.5 + 3.3.0 3.13.0 1.9.22.1 From 148405b45aae51f5cd644c0de204e385e8868d7f Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Wed, 24 Jul 2024 21:32:18 +0200 Subject: [PATCH 171/191] chore: library updates --- pom.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 4293609..43b978b 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.4.4 + 3.4.5 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -18,23 +18,23 @@ 22 UTF-8 UTF-8 - 3.2.5 + 3.3.1 3.13.0 1.9.22.1 - 4.21.0 + 4.23.0 7.10.2 - 3.26.0 - 2.2.2 + 3.26.3 + 2.3.1 2.23.1 1.0.12 - 2.27.0 + 2.28.0 2.12.0 1.0.0 https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline - 1.19.8 + 1.20.0 1.26.2 From d5aa6472ff4f438cf36a0393268ff8c98dfbe044 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sun, 20 Oct 2024 23:00:57 +0200 Subject: [PATCH 172/191] chore: library updates --- pom.xml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 31a39ba..75a9b5e 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.4.5 + 3.4.6 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -18,26 +18,26 @@ 22 UTF-8 UTF-8 - 3.3.0 + 3.5.1 3.13.0 1.9.22.1 - 4.23.0 + 4.25.0 7.10.2 3.26.3 - 2.3.1 + 2.4.0 2.23.1 1.0.12 - 2.28.0 - 2.12.0 + 2.29.0 + 2.14.0 1.0.0 https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline - 1.20.0 + 1.20.2 - 1.26.2 + 1.27.1 local From 3854636bc24d831353e5c0d1883425daf6062d87 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sun, 27 Oct 2024 16:25:01 +0100 Subject: [PATCH 173/191] chore: general refactor --- .../com/eliasnogueira/config/ConfigurationManager.java | 1 - src/main/java/com/eliasnogueira/driver/BrowserFactory.java | 7 ++++++- src/main/java/com/eliasnogueira/enums/RoomType.java | 2 +- src/main/java/com/eliasnogueira/model/Booking.java | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/eliasnogueira/config/ConfigurationManager.java b/src/main/java/com/eliasnogueira/config/ConfigurationManager.java index ba842b4..ce15843 100644 --- a/src/main/java/com/eliasnogueira/config/ConfigurationManager.java +++ b/src/main/java/com/eliasnogueira/config/ConfigurationManager.java @@ -35,4 +35,3 @@ public static Configuration configuration() { return ConfigCache.getOrCreate(Configuration.class); } } - diff --git a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java index 3bb5dd4..0b7f43f 100644 --- a/src/main/java/com/eliasnogueira/driver/BrowserFactory.java +++ b/src/main/java/com/eliasnogueira/driver/BrowserFactory.java @@ -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 { diff --git a/src/main/java/com/eliasnogueira/enums/RoomType.java b/src/main/java/com/eliasnogueira/enums/RoomType.java index 94844d1..e62f586 100644 --- a/src/main/java/com/eliasnogueira/enums/RoomType.java +++ b/src/main/java/com/eliasnogueira/enums/RoomType.java @@ -45,4 +45,4 @@ public static RoomType getRandom() { public String get() { return this.value; } -} \ No newline at end of file +} diff --git a/src/main/java/com/eliasnogueira/model/Booking.java b/src/main/java/com/eliasnogueira/model/Booking.java index 01bd9b4..5348d03 100644 --- a/src/main/java/com/eliasnogueira/model/Booking.java +++ b/src/main/java/com/eliasnogueira/model/Booking.java @@ -78,4 +78,4 @@ public Booking build() { return new Booking(email, country, password, dailyBudget, newsletter, roomType, roomDescription); } } -} \ No newline at end of file +} From 1832f49db1c6bb329745c4b20ef43b39783ad2d0 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sun, 27 Oct 2024 16:25:16 +0100 Subject: [PATCH 174/191] chore: selenium grid changes --- grid/config.toml | 14 ++++++++++---- grid/docker-compose.yml | 5 +++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/grid/config.toml b/grid/config.toml index 518c9d4..2d961ae 100644 --- a/grid/config.toml +++ b/grid/config.toml @@ -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" diff --git a/grid/docker-compose.yml b/grid/docker-compose.yml index 498c08a..7163cac 100644 --- a/grid/docker-compose.yml +++ b/grid/docker-compose.yml @@ -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: @@ -18,4 +19,4 @@ services: ports: - "4442:4442" - "4443:4443" - - "4444:4444" \ No newline at end of file + - "4444:4444" From eb2fd862042858fb0ca84adb746e8c3d260c78e6 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sun, 27 Oct 2024 16:25:24 +0100 Subject: [PATCH 175/191] chore: library updates --- README.MD | 27 +++++++++++++++++---------- pom.xml | 6 +++--- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/README.MD b/README.MD index 083075d..b15da45 100644 --- a/README.MD +++ b/README.MD @@ -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 @@ -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 ``` @@ -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. @@ -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: @@ -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 @@ -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. @@ -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 diff --git a/pom.xml b/pom.xml index 75a9b5e..be5b264 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.4.6 + 3.4.7 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -25,7 +25,7 @@ 4.25.0 7.10.2 3.26.3 - 2.4.0 + 2.4.1 2.23.1 1.0.12 2.29.0 @@ -34,7 +34,7 @@ https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline - 1.20.2 + 1.20.3 1.27.1 From 0ff9f30753ebe94bf02956c813f0efbfc9269f7e Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sun, 10 Nov 2024 22:03:45 +0100 Subject: [PATCH 176/191] chore: library updates --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index be5b264..7ea4a48 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.4.7 + 3.4.8 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -18,18 +18,18 @@ 22 UTF-8 UTF-8 - 3.5.1 + 3.5.2 3.13.0 1.9.22.1 - 4.25.0 + 4.26.0 7.10.2 3.26.3 2.4.1 2.23.1 1.0.12 2.29.0 - 2.14.0 + 2.15.0 1.0.0 https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline From 7eccc4729ba7f45308f37ad5c564e8c61d10c4d0 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Wed, 13 Nov 2024 21:12:32 +0100 Subject: [PATCH 177/191] chore: bump allure report --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7ea4a48..22c1f48 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ 2.23.1 1.0.12 2.29.0 - 2.15.0 + 2.15.1 1.0.0 https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline From 2b3446e6ce4cb75578c8ae132086bfb2a4d5c386 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Tue, 10 Dec 2024 21:42:19 +0100 Subject: [PATCH 178/191] chore: library updates --- pom.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 22c1f48..0ff9098 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.4.8 + 3.4.9 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -22,19 +22,19 @@ 3.13.0 1.9.22.1 - 4.26.0 + 4.27.0 7.10.2 3.26.3 - 2.4.1 + 2.4.2 2.23.1 1.0.12 - 2.29.0 - 2.15.1 + 2.29.1 + 2.15.3 1.0.0 https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline - 1.20.3 + 1.20.4 1.27.1 From 3a2db389ccbbbe6f108fb529b7b586247849da85 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Tue, 10 Dec 2024 21:42:28 +0100 Subject: [PATCH 179/191] feat: added workflow on pr --- .github/workflows/on-pr.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/on-pr.yml diff --git a/.github/workflows/on-pr.yml b/.github/workflows/on-pr.yml new file mode 100644 index 0000000..2dd02b8 --- /dev/null +++ b/.github/workflows/on-pr.yml @@ -0,0 +1,28 @@ +name: On Pull Request + +on: + pull_request: + branches: + - main + +jobs: + build: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 23 + uses: actions/setup-java@v4 + with: + distribution: oracle + java-version: 23 + + - name: Cache Maven packages + uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Build + run: mvn clean -q compile From b0efbf8cf7d788dac71508cf02375491dd43df6e Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sun, 22 Dec 2024 18:17:44 +0100 Subject: [PATCH 180/191] chore: library update --- pom.xml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 0ff9098..2cd74ff 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.4.9 + 3.4.10 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -24,9 +24,9 @@ 1.9.22.1 4.27.0 7.10.2 - 3.26.3 + 3.27.0 2.4.2 - 2.23.1 + 2.24.3 1.0.12 2.29.1 2.15.3 @@ -53,12 +53,6 @@ org.testng testng ${testng.version} - - - org.webjars - jquery - - From 00b34301871a287734180f11fdfdb8e1e92742de Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Mon, 13 Jan 2025 13:13:40 +0100 Subject: [PATCH 181/191] chore: bump assertJ --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 2cd74ff..8bed0ce 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.4.10 + 3.4.11 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -24,7 +24,7 @@ 1.9.22.1 4.27.0 7.10.2 - 3.27.0 + 3.27.2 2.4.2 2.24.3 1.0.12 From 0ce2877c3b20a452870c8c0d6f35f2a6786acd3c Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sun, 16 Mar 2025 18:22:08 +0100 Subject: [PATCH 182/191] chore: replace custom method by datafaker --- .../java/com/eliasnogueira/data/dynamic/BookingDataFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java b/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java index 644b3c3..c1dc321 100644 --- a/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java +++ b/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java @@ -49,7 +49,7 @@ public static Booking createBookingData() { password(faker.internet().password()). dailyBudget(returnDailyBudget()). newsletter(faker.bool().bool()). - roomType(RoomType.getRandom()). + roomType(faker.options().option(RoomType.class)). roomDescription(faker.lorem().paragraph()). build(); From c5efd7a7cb58e5b8fb307f29582ffabff29701fe Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sun, 16 Mar 2025 18:22:24 +0100 Subject: [PATCH 183/191] chore: cleanup workflow --- .github/workflows/on-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-pr.yml b/.github/workflows/on-pr.yml index 2dd02b8..4840f81 100644 --- a/.github/workflows/on-pr.yml +++ b/.github/workflows/on-pr.yml @@ -25,4 +25,4 @@ jobs: ${{ runner.os }}-maven- - name: Build - run: mvn clean -q compile + run: mvn -q compile From 20f6f1024867e7bf6b7dd48f9775cee2cd2b9633 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sun, 16 Mar 2025 18:22:31 +0100 Subject: [PATCH 184/191] chore: bump libraries --- pom.xml | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 8bed0ce..da1cc96 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.4.11 + 3.5.0 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -15,26 +15,29 @@ - 22 + 23 UTF-8 UTF-8 3.5.2 3.13.0 - 1.9.22.1 - 4.27.0 - 7.10.2 + 1.9.23 + 4.29.0 + 7.11.0 3.27.2 2.4.2 2.24.3 1.0.12 - 2.29.1 - 2.15.3 + 2.33.0 + 2.29.1 + 2.29.1 + 2.15.2 1.0.0 https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline - 1.20.4 + 1.20.6 + 2.0.17 1.27.1 @@ -94,13 +97,13 @@ io.qameta.allure allure-testng - ${allure.version} + ${allure-testng.version} io.qameta.allure allure-attachments - ${allure.version} + ${allure-attachments.version} @@ -127,6 +130,13 @@ + + org.slf4j + slf4j-simple + ${slf4j-simple.version} + test + + org.apache.commons From 412e8ba943c769c85311efe2b23abeb35a0b2d22 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sun, 16 Mar 2025 18:22:49 +0100 Subject: [PATCH 185/191] chore: bump libraries --- .github/workflows/test-execution.yml | 6 +++--- README.MD | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index 24d764d..8ac8c3b 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -15,7 +15,7 @@ jobs: - name: Set up JDK uses: actions/setup-java@v4 with: - java-version: 22 + java-version: 23 distribution: oracle - name: Cache Maven packages @@ -27,7 +27,7 @@ jobs: ${{ runner.os }}-maven- - name: Build with Maven - run: mvn -B -q -DskipTests package + run: mvn -q -DskipTests package - name: Run local tests - run: mvn -B -q test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome + run: mvn -q test -Pweb-execution -Dsuite=local -Dtarget=local -Dheadless=true -Dbrowser=chrome diff --git a/README.MD b/README.MD index b15da45..d90fecc 100644 --- a/README.MD +++ b/README.MD @@ -26,7 +26,7 @@ It has a complete solution to run tests in different ways: This project uses the following languages and frameworks: -* [Java 22](https://openjdk.java.net/projects/jdk/22/) as the programming language +* [Java 23](https://openjdk.java.net/projects/jdk/23/) as the programming language * [TestNG](https://testng.org/doc/) as the UnitTest framework to support the test creation * [Selenium WebDriver](https://www.selenium.dev/) as the web browser automation framework using the Java binding * [AssertJ](https://joel-costigliola.github.io/assertj/) as the fluent assertion library From b507e7192273a46673000c94b432dd995fd13ab8 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sun, 16 Mar 2025 18:22:58 +0100 Subject: [PATCH 186/191] chore: remove custom method --- src/main/java/com/eliasnogueira/enums/RoomType.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/com/eliasnogueira/enums/RoomType.java b/src/main/java/com/eliasnogueira/enums/RoomType.java index e62f586..d7b0980 100644 --- a/src/main/java/com/eliasnogueira/enums/RoomType.java +++ b/src/main/java/com/eliasnogueira/enums/RoomType.java @@ -24,7 +24,6 @@ package com.eliasnogueira.enums; -import java.security.SecureRandom; import java.util.function.Supplier; public enum RoomType implements Supplier { @@ -37,10 +36,6 @@ public enum RoomType implements Supplier { this.value = value; } - public static RoomType getRandom() { - return values()[new SecureRandom().nextInt(values().length)]; - } - @Override public String get() { return this.value; From cef666803445f2873283410b53c253dfcfb04f58 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Sun, 16 Mar 2025 18:23:06 +0100 Subject: [PATCH 187/191] chore: fix format --- src/main/java/com/eliasnogueira/driver/TargetFactory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eliasnogueira/driver/TargetFactory.java b/src/main/java/com/eliasnogueira/driver/TargetFactory.java index 434c1a2..3919b61 100644 --- a/src/main/java/com/eliasnogueira/driver/TargetFactory.java +++ b/src/main/java/com/eliasnogueira/driver/TargetFactory.java @@ -60,9 +60,9 @@ private RemoteWebDriver createRemoteInstance(MutableCapabilities capability) { remoteWebDriver = new RemoteWebDriver(URI.create(gridURL).toURL(), capability); } catch (java.net.MalformedURLException e) { logger.error("Grid URL is invalid or Grid is not available"); - logger.error(format("Browser: %s", capability.getBrowserName()), e); + logger.error("Browser: {}", capability.getBrowserName(), e); } catch (IllegalArgumentException e) { - logger.error(format("Browser %s is not valid or recognized", capability.getBrowserName()), e); + logger.error("Browser {} is not valid or recognized", capability.getBrowserName(), e); } return remoteWebDriver; From 687929d2b40381aa729c36db4e3d4e743c09b044 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Mon, 31 Mar 2025 21:32:23 +0200 Subject: [PATCH 188/191] chore: update selenium and maven surefire plugin version --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index da1cc96..2736d0f 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.5.0 + 3.6.0 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -18,11 +18,11 @@ 23 UTF-8 UTF-8 - 3.5.2 + 3.5.3 3.13.0 1.9.23 - 4.29.0 + 4.30.0 7.11.0 3.27.2 2.4.2 From d89ec930ffaf38408d2cba7042ee0962fc452ad9 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Tue, 13 May 2025 19:11:31 +0200 Subject: [PATCH 189/191] chore: update dependencies --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 2736d0f..c5819ec 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.6.0 + 3.7.0 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -22,10 +22,10 @@ 3.13.0 1.9.23 - 4.30.0 + 4.32.0 7.11.0 3.27.2 - 2.4.2 + 2.4.3 2.24.3 1.0.12 2.33.0 @@ -36,7 +36,7 @@ https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline - 1.20.6 + 1.21.0 2.0.17 From 923578e062d3a0e2f33f31c18f824a5873bc0f8f Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Wed, 23 Jul 2025 22:04:23 +0200 Subject: [PATCH 190/191] chore: latest updates --- .github/workflows/on-pr.yml | 4 ++-- .github/workflows/test-execution.yml | 4 ++-- pom.xml | 30 ++++++++++------------------ 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/.github/workflows/on-pr.yml b/.github/workflows/on-pr.yml index 4840f81..69175b4 100644 --- a/.github/workflows/on-pr.yml +++ b/.github/workflows/on-pr.yml @@ -10,11 +10,11 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v4 - - name: Set up JDK 23 + - name: Set up JDK 24 uses: actions/setup-java@v4 with: distribution: oracle - java-version: 23 + java-version: 24 - name: Cache Maven packages uses: actions/cache@v4 diff --git a/.github/workflows/test-execution.yml b/.github/workflows/test-execution.yml index 8ac8c3b..338cdd1 100644 --- a/.github/workflows/test-execution.yml +++ b/.github/workflows/test-execution.yml @@ -12,10 +12,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK + - name: Set up JDK 24 uses: actions/setup-java@v4 with: - java-version: 23 + java-version: 24 distribution: oracle - name: Cache Maven packages diff --git a/pom.xml b/pom.xml index c5819ec..3541b74 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eliasnogueira selenium-java-lean-test-architecture - 3.7.0 + 3.8.0 scm:git@github.com:eliasnogueira/selenium-java-lean-test-architecture.git @@ -15,18 +15,18 @@ - 23 + 24 UTF-8 UTF-8 3.5.3 - 3.13.0 + 3.14.0 - 1.9.23 - 4.32.0 + 1.9.24 + 4.34.0 7.11.0 - 3.27.2 - 2.4.3 - 2.24.3 + 3.27.3 + 2.4.4 + 2.25.1 1.0.12 2.33.0 2.29.1 @@ -36,12 +36,9 @@ https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline - 1.21.0 + 1.21.3 2.0.17 - - 1.27.1 - local @@ -137,16 +134,9 @@ test - - - org.apache.commons - commons-compress - ${commons-compress.version} - - - + web-execution From d0e1f6795475ee598747bff8b750fea395572158 Mon Sep 17 00:00:00 2001 From: eliasnogueira Date: Mon, 8 Sep 2025 22:11:52 +0200 Subject: [PATCH 191/191] chore: latest updates --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 3541b74..d3faf76 100644 --- a/pom.xml +++ b/pom.xml @@ -22,9 +22,9 @@ 3.14.0 1.9.24 - 4.34.0 + 4.35.0 7.11.0 - 3.27.3 + 3.27.4 2.4.4 2.25.1 1.0.12