Skip to content

Commit

Permalink
Update Selenium 4.22.0
Browse files Browse the repository at this point in the history
  • Loading branch information
anhtester committed Jun 23, 2024
1 parent 656087f commit 6202b96
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 25 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
v2.4.1
======
Jun 24, 2024
* Update Selenium 4.22.0
* Update support CDP 126 (Chromium)
* Update CDP 126 in WebUI keyword

v2.4.0
======
May 22, 2024
Expand Down
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

### ✳️ **SYSTEM REQUIREMENTS**

- Install JDK (recommend JDK >=11)
- Install JDK (recommend JDK >= 11)
- Install Chrome Browser, Edge Browser, Firefox Browser
- Run well on the **Windows** platform
- Setup **Allure ENV**:
Expand Down Expand Up @@ -74,7 +74,8 @@

**4. Allure Report**

- Open Terminal: **_allure serve target/allure-results_**
- Open Terminal: `allure serve target/allure-results`
- or command: `allure generate --single-file target/allure-results --clean`

![image](https://user-images.githubusercontent.com/87883620/161662507-9e4dc698-e452-4b43-a4f5-9808c81419a2.png)

Expand Down Expand Up @@ -182,32 +183,32 @@

(tải bản Latest stable version)

**selenium-server-4.9.0.jar** (updated 21/04/2023)
**selenium-server-4.22.0.jar** (updated 24/06/2024)

2. Set PATH for driver in Environment variables:

Follow with link:
https://www.selenium.dev/documentation/webdriver/getting_started/install_drivers/#2-the-path-environment-variable

🔆 Đặt file **selenium-server-4.9.0.jar** vào thư mục nào đó và mở CMD tại thư mục đó lên
🔆 Đặt file **selenium-server-4.22.0.jar** vào thư mục nào đó và mở CMD tại thư mục đó lên

### Run default 1 node

✅ Mở 1 Hub với 1 Node mặc định (port 4444)

> java -jar selenium-server-4.9.0.jar standalone
> java -jar selenium-server-4.22.0.jar standalone
### Run multi Node

✅ Mở 1 Hub với 3 Node: (chạy 4 lệnh mở 4 CMD nhé)

> java -jar selenium-server-4.9.0.jar hub
> java -jar selenium-server-4.22.0.jar hub
> java -jar selenium-server-4.9.0.jar node --port 5556
> java -jar selenium-server-4.22.0.jar node --port 5556
> java -jar selenium-server-4.9.0.jar node --port 6667
> java -jar selenium-server-4.22.0.jar node --port 6667
> java -jar selenium-server-4.9.0.jar node --port 7778
> java -jar selenium-server-4.22.0.jar node --port 7778

**📝 NOTE: Thực thi nhiều lệnh thì mở nhiều CMD**
Expand All @@ -229,6 +230,8 @@ https://www.selenium.dev/documentation/webdriver/getting_started/install_drivers
**15. Use DataFaker and JavaFaker to generate data**

Document DataFaker: https://www.datafaker.net/documentation/getting-started/
or of Anh Tester blog: https://anhtester.com/blog/selenium-java/tao-du-lieu-gia-voi-datafaker


### 🔆 Project structure

Expand Down Expand Up @@ -584,10 +587,10 @@ Document DataFaker: https://www.datafaker.net/documentation/getting-started/
┗ 📜README.md
```

### I shall write document for my Framework. Coming soon...
### ⭐️ I will support your company if needed

## Copyright 2022 Anh Tester
## Copyright 2022-2024 Anh Tester

> Anh Tester Blog: https://anhtester.com/
![Alt text](https://anhtester.com/uploads/logo/anhtester_logo_512.png?raw=true "Anh Tester - Automation Testing")
![Alt text](https://anhtester.com/uploads/logo/anhtester_logo_512.png?raw=true "Anh Tester Automation Testing")
28 changes: 28 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[docker]
# 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.21.0-20240522", '{"browserName": "firefox"}',
"selenium/standalone-chrome:4.21.0-20240522", '{"browserName": "chrome"}',
"selenium/standalone-edge:4.21.0-20240522", '{"browserName": "MicrosoftEdge"}'
]

host-config-keys = ["Dns", "DnsOptions", "DnsSearch", "ExtraHosts", "Binds"]

# URL for connecting to the docker daemon
# 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://127.0.0.1:2375"
# Docker image used for video recording
video-image = "selenium/video:ffmpeg-6.1.1-20240522"

# Uncomment the following section if you are running the node on a separate VM
# Fill out the placeholders with appropriate values
#[server]
#host = <ip-from-node-machine>
#port = <port-from-node-machine>
25 changes: 25 additions & 0 deletions docker-compose-v3-dynamic-grid.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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:
image: selenium/node-docker:4.21.0-20240522
volumes:
- ./assets:/opt/selenium/assets
- ./NodeDocker/config.toml:/opt/bin/config.toml
- /var/run/docker.sock:/var/run/docker.sock
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443

selenium-hub:
image: selenium/hub:4.21.0-20240522
container_name: selenium-hub
ports:
- "4442:4442"
- "4443:4443"
- "4444:4444"
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java-compiler.version>17</java-compiler.version>
<maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version>
<maven-surefire-plugin.version>3.3.0</maven-surefire-plugin.version>
<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
<selenium.version>4.21.0</selenium.version>
<selenium.version>4.22.0</selenium.version>
<testng.version>7.10.2</testng.version>
<aspectjweaver.version>1.9.22.1</aspectjweaver.version>
<ashot.version>1.5.4</ashot.version>
Expand All @@ -43,17 +43,17 @@
<apache-poi.version>5.2.5</apache-poi.version>
<commons-io.version>2.16.1</commons-io.version>
<owner.version>1.0.12</owner.version>
<assertj.version>3.25.3</assertj.version>
<assertj.version>3.26.0</assertj.version>
<datafaker.version>2.2.2</datafaker.version>
<monte-screen-recorder.version>0.7.7.0</monte-screen-recorder.version>
<mysql-connector-java.version>8.0.33</mysql-connector-java.version>
<google.zxing.version>3.5.3</google.zxing.version>
<lombok.version>1.18.32</lombok.version>
<google.guava.version>33.2.0-jre</google.guava.version>
<google.guava.version>33.2.1-jre</google.guava.version>
<javax.mail.version>1.6.2</javax.mail.version>
<zip.version>1.17</zip.version>
<jackson.version>2.17.1</jackson.version>
<java-telegram-bot-api.version>7.2.1</java-telegram-bot-api.version>
<java-telegram-bot-api.version>7.4.0</java-telegram-bot-api.version>
<commons-lang3.version>3.14.0</commons-lang3.version>
<mysql-connector-j.version>8.4.0</mysql-connector-j.version>
<json-path.version>2.9.0</json-path.version>
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/anhtester/keywords/WebUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.HasDevTools;
import org.openqa.selenium.devtools.v125.network.Network;
import org.openqa.selenium.devtools.v125.network.model.Headers;
import org.openqa.selenium.devtools.v126.network.Network;
import org.openqa.selenium.devtools.v126.network.model.Headers;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.print.PrintOptions;
import org.openqa.selenium.support.ui.ExpectedCondition;
Expand Down Expand Up @@ -2675,7 +2675,7 @@ public static void clearAndFillText(By by, String value) {
*/
@Step("Click on the element {0}")
public static void clickElement(By by) {
waitForElementVisible(by).click();
waitForElementClickable(by).click();
LogUtils.info("Clicked on the element " + by.toString());

if (ExtentTestManager.getExtentTest() != null) {
Expand All @@ -2694,7 +2694,7 @@ public static void clickElement(By by) {
*/
@Step("Click on the element {0} with timeout {1}s")
public static void clickElement(By by, int timeout) {
waitForElementVisible(by, timeout).click();
waitForElementClickable(by, timeout).click();
LogUtils.info("Clicked on the element " + by.toString());

if (ExtentTestManager.getExtentTest() != null) {
Expand Down Expand Up @@ -2758,7 +2758,7 @@ public static void clickLinkText(String linkText) {
@Step("Right click on element {0}")
public static void rightClickElement(By by) {
Actions action = new Actions(DriverManager.getDriver());
action.contextClick(waitForElementVisible(by)).build().perform();
action.contextClick(waitForElementClickable(by)).build().perform();
LogUtils.info("Right click on element " + by);
if (ExtentTestManager.getExtentTest() != null) {
ExtentReportManager.pass("Right click on element " + by);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/anhtester/listeners/AllureListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ public void afterTestStart(TestResult result) {

@Override
public void beforeTestStop(TestResult result) {
if (SCREENSHOT_PASSED_TCS.equals(YES)) {
if (SCREENSHOT_PASSED_TCS.equals(YES) && result.getStatus().equals(Status.PASSED)) {
if (DriverManager.getDriver() != null) {
Allure.addAttachment(result.getName() + "_Passed_Screenshot", new ByteArrayInputStream(((TakesScreenshot) DriverManager.getDriver()).getScreenshotAs(OutputType.BYTES)));
}
}
if (SCREENSHOT_FAILED_TCS.equals(YES)) {
if (SCREENSHOT_FAILED_TCS.equals(YES) && result.getStatus().equals(Status.FAILED)) {
if (DriverManager.getDriver() != null) {
Allure.addAttachment(result.getName() + "_Failed_Screenshot", new ByteArrayInputStream(((TakesScreenshot) DriverManager.getDriver()).getScreenshotAs(OutputType.BYTES)));
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/config/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ URL_CRM = https://rise.anhtester.com/signin
URL_CMS_ADMIN = https://cms.anhtester.com/login
URL_CMS_USER = https://cms.anhtester.com
# target execution: local or remote
TARGET = remote
TARGET = local
# grid url and port
REMOTE_URL = localhost
REMOTE_PORT = 4444
Expand Down

0 comments on commit 6202b96

Please sign in to comment.