Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Automation_selenium
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Trình Nguyễn
Automation_selenium
Commits
69c5e582
Commit
69c5e582
authored
May 04, 2026
by
Đỗ Gia Hưng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bai 7: Su dung cac ham co ban cua WebDriver
parent
98cfac47
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
103 additions
and
0 deletions
+103
-0
pom.xml
pom.xml
+36
-0
BasicWebDriverCommandsTest.java
.../com/automation/testcases/BasicWebDriverCommandsTest.java
+67
-0
No files found.
pom.xml
0 → 100644
View file @
69c5e582
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.automation
</groupId>
<artifactId>
automation_selenium
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<properties>
<maven.compiler.source>
11
</maven.compiler.source>
<maven.compiler.target>
11
</maven.compiler.target>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<selenium.version>
4.19.1
</selenium.version>
<testng.version>
7.9.0
</testng.version>
</properties>
<dependencies>
<!-- Selenium WebDriver -->
<dependency>
<groupId>
org.seleniumhq.selenium
</groupId>
<artifactId>
selenium-java
</artifactId>
<version>
${selenium.version}
</version>
</dependency>
<!-- TestNG -->
<dependency>
<groupId>
org.testng
</groupId>
<artifactId>
testng
</artifactId>
<version>
${testng.version}
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
</project>
src/test/java/com/automation/testcases/BasicWebDriverCommandsTest.java
0 → 100644
View file @
69c5e582
package
com
.
automation
.
testcases
;
import
org.openqa.selenium.WebDriver
;
import
org.openqa.selenium.chrome.ChromeDriver
;
import
org.testng.annotations.AfterMethod
;
import
org.testng.annotations.BeforeMethod
;
import
org.testng.annotations.Test
;
import
java.time.Duration
;
public
class
BasicWebDriverCommandsTest
{
WebDriver
driver
;
@BeforeMethod
public
void
setUp
()
{
// Khởi tạo WebDriver
driver
=
new
ChromeDriver
();
// --- 4. Thiết lập thời gian chờ (Wait Configurations) ---
driver
.
manage
().
timeouts
().
implicitlyWait
(
Duration
.
ofSeconds
(
10
));
driver
.
manage
().
timeouts
().
pageLoadTimeout
(
Duration
.
ofSeconds
(
30
));
// --- 3. Quản lý cửa sổ (Window Management) ---
driver
.
manage
().
window
().
maximize
();
// Phóng to toàn màn hình
}
@Test
public
void
testBasicCommands
()
throws
InterruptedException
{
// --- 1. Các hàm cơ bản (Basic Browser Operations) ---
System
.
out
.
println
(
"Mở trang web Anh Tester..."
);
driver
.
get
(
"https://anhtester.com"
);
System
.
out
.
println
(
"Tiêu đề trang: "
+
driver
.
getTitle
());
System
.
out
.
println
(
"URL hiện tại: "
+
driver
.
getCurrentUrl
());
System
.
out
.
println
(
"Độ dài mã nguồn: "
+
driver
.
getPageSource
().
length
());
Thread
.
sleep
(
2000
);
// Demo mục đích quan sát
// --- 2. Các hàm điều hướng (Navigation Operations) ---
System
.
out
.
println
(
"\nChuyển hướng sang Google..."
);
driver
.
navigate
().
to
(
"https://google.com"
);
System
.
out
.
println
(
"Đã chuyển sang: "
+
driver
.
getTitle
());
Thread
.
sleep
(
2000
);
System
.
out
.
println
(
"Quay lại (Back)..."
);
driver
.
navigate
().
back
();
System
.
out
.
println
(
"Trang hiện tại: "
+
driver
.
getTitle
());
Thread
.
sleep
(
2000
);
System
.
out
.
println
(
"Đi tới (Forward)..."
);
driver
.
navigate
().
forward
();
System
.
out
.
println
(
"Tải lại trang (Refresh)..."
);
driver
.
navigate
().
refresh
();
}
@AfterMethod
public
void
tearDown
()
{
if
(
driver
!=
null
)
{
driver
.
quit
();
// Đóng toàn bộ trình duyệt
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment