Skip to content

Commit 6202b96

Browse files
committed
Update Selenium 4.22.0
1 parent 656087f commit 6202b96

File tree

8 files changed

+88
-25
lines changed

8 files changed

+88
-25
lines changed

CHANGELOG.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
v2.4.1
2+
======
3+
Jun 24, 2024
4+
* Update Selenium 4.22.0
5+
* Update support CDP 126 (Chromium)
6+
* Update CDP 126 in WebUI keyword
7+
18
v2.4.0
29
======
310
May 22, 2024

README.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
### ✳️ **SYSTEM REQUIREMENTS**
2828

29-
- Install JDK (recommend JDK >=11)
29+
- Install JDK (recommend JDK >= 11)
3030
- Install Chrome Browser, Edge Browser, Firefox Browser
3131
- Run well on the **Windows** platform
3232
- Setup **Allure ENV**:
@@ -74,7 +74,8 @@
7474

7575
**4. Allure Report**
7676

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

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

@@ -182,32 +183,32 @@
182183

183184
(tải bản Latest stable version)
184185

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

187188
2. Set PATH for driver in Environment variables:
188189

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

192-
🔆 Đặ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
193+
🔆 Đặ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
193194

194195
### Run default 1 node
195196

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

198-
> java -jar selenium-server-4.9.0.jar standalone
199+
> java -jar selenium-server-4.22.0.jar standalone
199200
200201
### Run multi Node
201202

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

204-
> java -jar selenium-server-4.9.0.jar hub
205+
> java -jar selenium-server-4.22.0.jar hub
205206
206-
> java -jar selenium-server-4.9.0.jar node --port 5556
207+
> java -jar selenium-server-4.22.0.jar node --port 5556
207208
208-
> java -jar selenium-server-4.9.0.jar node --port 6667
209+
> java -jar selenium-server-4.22.0.jar node --port 6667
209210
210-
> java -jar selenium-server-4.9.0.jar node --port 7778
211+
> java -jar selenium-server-4.22.0.jar node --port 7778
211212
212213

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

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

233236
### 🔆 Project structure
234237

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

587-
### I shall write document for my Framework. Coming soon...
590+
### ⭐️ I will support your company if needed
588591

589-
## Copyright 2022 Anh Tester
592+
## Copyright 2022-2024 Anh Tester
590593

591594
> Anh Tester Blog: https://anhtester.com/
592595
593-
![Alt text](https://anhtester.com/uploads/logo/anhtester_logo_512.png?raw=true "Anh Tester - Automation Testing")
596+
![Alt text](https://anhtester.com/uploads/logo/anhtester_logo_512.png?raw=true "Anh Tester Automation Testing")

config.toml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[docker]
2+
# Configs have a mapping between the Docker image to use and the capabilities that need to be matched to
3+
# start a container with the given image.
4+
configs = [
5+
"selenium/standalone-firefox:4.21.0-20240522", '{"browserName": "firefox"}',
6+
"selenium/standalone-chrome:4.21.0-20240522", '{"browserName": "chrome"}',
7+
"selenium/standalone-edge:4.21.0-20240522", '{"browserName": "MicrosoftEdge"}'
8+
]
9+
10+
host-config-keys = ["Dns", "DnsOptions", "DnsSearch", "ExtraHosts", "Binds"]
11+
12+
# URL for connecting to the docker daemon
13+
# Most simple approach, leave it as http://127.0.0.1:2375, and mount /var/run/docker.sock.
14+
# 127.0.0.1 is used because internally the container uses socat when /var/run/docker.sock is mounted
15+
# If var/run/docker.sock is not mounted:
16+
# Windows: make sure Docker Desktop exposes the daemon via tcp, and use http://host.docker.internal:2375.
17+
# macOS: install socat and run the following command, socat -4 TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock,
18+
# then use http://host.docker.internal:2375.
19+
# Linux: varies from machine to machine, please mount /var/run/docker.sock. If this does not work, please create an issue.
20+
url = "http://127.0.0.1:2375"
21+
# Docker image used for video recording
22+
video-image = "selenium/video:ffmpeg-6.1.1-20240522"
23+
24+
# Uncomment the following section if you are running the node on a separate VM
25+
# Fill out the placeholders with appropriate values
26+
#[server]
27+
#host = <ip-from-node-machine>
28+
#port = <port-from-node-machine>

docker-compose-v3-dynamic-grid.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# To execute this docker compose yml file use `docker compose -f docker-compose-v3-dynamic-grid.yml up`
2+
# Add the `-d` flag at the end for detached execution
3+
# To stop the execution, hit Ctrl+C, and then `docker compose -f docker-compose-v3-dynamic-grid.yml down`
4+
version: "3"
5+
services:
6+
node-docker:
7+
image: selenium/node-docker:4.21.0-20240522
8+
volumes:
9+
- ./assets:/opt/selenium/assets
10+
- ./NodeDocker/config.toml:/opt/bin/config.toml
11+
- /var/run/docker.sock:/var/run/docker.sock
12+
depends_on:
13+
- selenium-hub
14+
environment:
15+
- SE_EVENT_BUS_HOST=selenium-hub
16+
- SE_EVENT_BUS_PUBLISH_PORT=4442
17+
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
18+
19+
selenium-hub:
20+
image: selenium/hub:4.21.0-20240522
21+
container_name: selenium-hub
22+
ports:
23+
- "4442:4442"
24+
- "4443:4443"
25+
- "4444:4444"

pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2525
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
2626
<java-compiler.version>17</java-compiler.version>
27-
<maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version>
27+
<maven-surefire-plugin.version>3.3.0</maven-surefire-plugin.version>
2828
<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
29-
<selenium.version>4.21.0</selenium.version>
29+
<selenium.version>4.22.0</selenium.version>
3030
<testng.version>7.10.2</testng.version>
3131
<aspectjweaver.version>1.9.22.1</aspectjweaver.version>
3232
<ashot.version>1.5.4</ashot.version>
@@ -43,17 +43,17 @@
4343
<apache-poi.version>5.2.5</apache-poi.version>
4444
<commons-io.version>2.16.1</commons-io.version>
4545
<owner.version>1.0.12</owner.version>
46-
<assertj.version>3.25.3</assertj.version>
46+
<assertj.version>3.26.0</assertj.version>
4747
<datafaker.version>2.2.2</datafaker.version>
4848
<monte-screen-recorder.version>0.7.7.0</monte-screen-recorder.version>
4949
<mysql-connector-java.version>8.0.33</mysql-connector-java.version>
5050
<google.zxing.version>3.5.3</google.zxing.version>
5151
<lombok.version>1.18.32</lombok.version>
52-
<google.guava.version>33.2.0-jre</google.guava.version>
52+
<google.guava.version>33.2.1-jre</google.guava.version>
5353
<javax.mail.version>1.6.2</javax.mail.version>
5454
<zip.version>1.17</zip.version>
5555
<jackson.version>2.17.1</jackson.version>
56-
<java-telegram-bot-api.version>7.2.1</java-telegram-bot-api.version>
56+
<java-telegram-bot-api.version>7.4.0</java-telegram-bot-api.version>
5757
<commons-lang3.version>3.14.0</commons-lang3.version>
5858
<mysql-connector-j.version>8.4.0</mysql-connector-j.version>
5959
<json-path.version>2.9.0</json-path.version>

src/main/java/com/anhtester/keywords/WebUI.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
import org.openqa.selenium.chrome.ChromeOptions;
3131
import org.openqa.selenium.devtools.DevTools;
3232
import org.openqa.selenium.devtools.HasDevTools;
33-
import org.openqa.selenium.devtools.v125.network.Network;
34-
import org.openqa.selenium.devtools.v125.network.model.Headers;
33+
import org.openqa.selenium.devtools.v126.network.Network;
34+
import org.openqa.selenium.devtools.v126.network.model.Headers;
3535
import org.openqa.selenium.interactions.Actions;
3636
import org.openqa.selenium.print.PrintOptions;
3737
import org.openqa.selenium.support.ui.ExpectedCondition;
@@ -2675,7 +2675,7 @@ public static void clearAndFillText(By by, String value) {
26752675
*/
26762676
@Step("Click on the element {0}")
26772677
public static void clickElement(By by) {
2678-
waitForElementVisible(by).click();
2678+
waitForElementClickable(by).click();
26792679
LogUtils.info("Clicked on the element " + by.toString());
26802680

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

27002700
if (ExtentTestManager.getExtentTest() != null) {
@@ -2758,7 +2758,7 @@ public static void clickLinkText(String linkText) {
27582758
@Step("Right click on element {0}")
27592759
public static void rightClickElement(By by) {
27602760
Actions action = new Actions(DriverManager.getDriver());
2761-
action.contextClick(waitForElementVisible(by)).build().perform();
2761+
action.contextClick(waitForElementClickable(by)).build().perform();
27622762
LogUtils.info("Right click on element " + by);
27632763
if (ExtentTestManager.getExtentTest() != null) {
27642764
ExtentReportManager.pass("Right click on element " + by);

src/test/java/com/anhtester/listeners/AllureListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ public void afterTestStart(TestResult result) {
4141

4242
@Override
4343
public void beforeTestStop(TestResult result) {
44-
if (SCREENSHOT_PASSED_TCS.equals(YES)) {
44+
if (SCREENSHOT_PASSED_TCS.equals(YES) && result.getStatus().equals(Status.PASSED)) {
4545
if (DriverManager.getDriver() != null) {
4646
Allure.addAttachment(result.getName() + "_Passed_Screenshot", new ByteArrayInputStream(((TakesScreenshot) DriverManager.getDriver()).getScreenshotAs(OutputType.BYTES)));
4747
}
4848
}
49-
if (SCREENSHOT_FAILED_TCS.equals(YES)) {
49+
if (SCREENSHOT_FAILED_TCS.equals(YES) && result.getStatus().equals(Status.FAILED)) {
5050
if (DriverManager.getDriver() != null) {
5151
Allure.addAttachment(result.getName() + "_Failed_Screenshot", new ByteArrayInputStream(((TakesScreenshot) DriverManager.getDriver()).getScreenshotAs(OutputType.BYTES)));
5252
}

src/test/resources/config/config.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ URL_CRM = https://rise.anhtester.com/signin
2121
URL_CMS_ADMIN = https://cms.anhtester.com/login
2222
URL_CMS_USER = https://cms.anhtester.com
2323
# target execution: local or remote
24-
TARGET = remote
24+
TARGET = local
2525
# grid url and port
2626
REMOTE_URL = localhost
2727
REMOTE_PORT = 4444

0 commit comments

Comments
 (0)