Skip to content

Commit 0ac969c

Browse files
committed
Update version 1.5.1
1 parent e0e87a8 commit 0ac969c

15 files changed

Lines changed: 122 additions & 94 deletions

File tree

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
**SOME FEATURES IN FRAMEWORK**
44

55
1. Run the parallel test case
6-
2. Read Object web element from a properties file
6+
2. Read Object web element from Properties file
77
3. Extent Report
88
4. Allure Report
99
5. Send Mail after the run test (Report information and HTML file attachment)
1010
6. Logfile
1111
7. Record video and Screenshot test case for failed
12-
8. Read data test form Excel file (xlsx, csv, json,...) with class define fields (param: Client client)
12+
8. Read data test from Excel file (xlsx, csv, json,...) with class define fields (param: Client client)
1313
9. Base function in the package: utils, helpers
14-
10. Read data from Json file
14+
10. Read data test from Json file
1515
11. Main Keyword: WebUI (call common function)
1616
12. Sample test function
1717

@@ -41,17 +41,17 @@
4141

4242
![image](https://user-images.githubusercontent.com/87883620/161658761-5040e527-b410-46b3-8697-3298523e201d.png)
4343

44-
**2. Read Object web element from a properties file**
44+
**2. Read Object web element from Properties file**
4545

4646
![image](https://user-images.githubusercontent.com/87883620/161658681-58f3a183-cbfd-433d-853a-927e4373f51c.png)
4747

4848
**3. Extent Report**
4949

50-
- Insert Framework Annotation as sample:
50+
- Insert "FrameworkAnnotation" as sample or none:
5151

5252
![image](https://user-images.githubusercontent.com/87883620/161657646-3dd652c6-a310-4006-a0cb-de63e2e87e36.png)
5353

54-
- Value from Enums (src/main/java/anhtester/com/enums)
54+
- The base value read from Enums (src/main/java/anhtester/com/enums)
5555
- Setup on TestListener and BaseTest
5656

5757
![image](https://user-images.githubusercontent.com/87883620/161657754-c29b1ee9-f2fb-44b3-bee0-9f425a7cab6f.png)
@@ -111,7 +111,7 @@
111111
- **_src/main/java/anhtester/com/utils_**
112112
- **_src/main/java/anhtester/com/helpers_**
113113

114-
**10. Read data from JSON file**
114+
**10. Read data test from JSON file**
115115

116116
- **JsonUtils** class select the json file path and call **"get"** method with **key**
117117

pom.xml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>anhtester.com</groupId>
88
<artifactId>AutomationFrameworkSelenium</artifactId>
9-
<version>1.5.0</version>
9+
<version>1.5.1</version>
1010
<name>AutomationFrameworkSelenium</name>
1111
<url>https://github.com/anhtester/AutomationFrameworkSelenium</url>
1212

@@ -17,23 +17,24 @@
1717
<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
1818
<maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version>
1919

20-
<selenium.version>4.2.1</selenium.version>
20+
<selenium.version>4.2.2</selenium.version>
2121
<testng.version>7.4.0</testng.version>
2222
<webdrivermanager.version>5.2.0</webdrivermanager.version>
2323
<aspectjweaver.version>1.9.9.1</aspectjweaver.version>
2424
<ashot.version>1.5.4</ashot.version>
2525
<log4j.version>2.17.2</log4j.version>
26-
<allure-testng.version>2.17.3</allure-testng.version>
26+
<allure-testng.version>2.18.1</allure-testng.version>
2727
<allure-maven.version>2.10.0</allure-maven.version>
2828
<allure-environment-writer.version>1.0.0</allure-environment-writer.version>
2929
<allure.cmd.download.url>
3030
https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline
3131
</allure.cmd.download.url>
3232
<extentreports.version>5.0.9</extentreports.version>
33-
<apache-poi.version>5.0.0</apache-poi.version>
34-
<apache-poi-xml.version>5.0.0</apache-poi-xml.version>
33+
<apache-poi.version>5.2.2</apache-poi.version>
34+
<apache-poi-xml.version>5.2.2</apache-poi-xml.version>
35+
<commons-io.version>2.11.0</commons-io.version>
3536
<owner.version>1.0.12</owner.version>
36-
<assertj.version>3.22.0</assertj.version>
37+
<assertj.version>3.23.1</assertj.version>
3738
<javafaker.version>1.0.2</javafaker.version>
3839
<monte-screen-recorder.version>0.7.7.0</monte-screen-recorder.version>
3940
<mysql-connector-java.version>8.0.29</mysql-connector-java.version>
@@ -204,6 +205,13 @@
204205
<version>${apache-poi-xml.version}</version>
205206
</dependency>
206207

208+
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
209+
<dependency>
210+
<groupId>commons-io</groupId>
211+
<artifactId>commons-io</artifactId>
212+
<version>${commons-io.version}</version>
213+
</dependency>
214+
207215
<!-- https://mvnrepository.com/artifact/com.github.stephenc.monte/monte-screen-recorder -->
208216
<dependency>
209217
<groupId>com.github.stephenc.monte</groupId>
@@ -286,8 +294,8 @@
286294
<configuration>
287295
<suiteXmlFiles>
288296
<!-- Call Suite name global set up above -->
289-
<suiteXmlFile>${suite.client.parallel}</suiteXmlFile>
290-
<!--<suiteXmlFile>${suite.signin.simple}</suiteXmlFile>-->
297+
<suiteXmlFile>${suite.client.simple}</suiteXmlFile>
298+
<!--<suiteXmlFile>${suite.client.parallel}</suiteXmlFile>-->
291299
</suiteXmlFiles>
292300

293301
<argLine>

src/main/java/anhtester/com/helpers/ExcelHelpers.java

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@
2020

2121
public class ExcelHelpers {
2222

23-
private static FileInputStream fis;
24-
private static FileOutputStream fileOut;
25-
private static Workbook wb;
26-
private static Sheet sh;
27-
private static Cell cell;
28-
private static Row row;
29-
private static CellStyle cellstyle;
30-
private static Color mycolor;
31-
private static String excelFilePath;
32-
private static Map<String, Integer> columns = new HashMap<>();
33-
34-
public static int rowNumber; //Row Number
35-
public static int columnNumber; //Column Number
23+
private FileInputStream fis;
24+
private FileOutputStream fileOut;
25+
private Workbook wb;
26+
private Sheet sh;
27+
private Cell cell;
28+
private Row row;
29+
private CellStyle cellstyle;
30+
private Color mycolor;
31+
private String excelFilePath;
32+
private Map<String, Integer> columns = new HashMap<>();
33+
34+
public int rowNumber; //Row Number
35+
public int columnNumber; //Column Number
3636

3737
// Set Excel file
38-
public static void setExcelFile(String excelPath, String sheetName) {
38+
public void setExcelFile(String excelPath, String sheetName) {
3939
try {
4040
File f = new File(excelPath);
4141

@@ -85,12 +85,12 @@ public static void setExcelFile(String excelPath, String sheetName) {
8585
}
8686

8787
//Phương thức này nhận số hàng làm tham số và trả về dữ liệu của hàng đó.
88-
public static Row getRowData(int rowNum) {
88+
public Row getRowData(int rowNum) {
8989
row = sh.getRow(rowNum);
9090
return row;
9191
}
9292

93-
public static Object[][] getDataArray(String excelPath, String sheetName, int startCol, int totalCols) {
93+
public Object[][] getDataArray(String excelPath, String sheetName, int startCol, int totalCols) {
9494

9595
Object[][] data = null;
9696
try {
@@ -147,7 +147,7 @@ public static Object[][] getDataArray(String excelPath, String sheetName, int st
147147
return data;
148148
}
149149

150-
public static Object[][] getTableArray(String filePath, String sheetName, int iTestCaseRow) throws Exception {
150+
public Object[][] getTableArray(String filePath, String sheetName, int iTestCaseRow) throws Exception {
151151

152152
String[][] tabArray = null;
153153

@@ -181,7 +181,7 @@ public static Object[][] getTableArray(String filePath, String sheetName, int iT
181181
return (tabArray);
182182
}
183183

184-
public static Object[][] getDataHashTable(String excelPath, String sheetName, int startRow, int endRow) {
184+
public Object[][] getDataHashTable(String excelPath, String sheetName, int startRow, int endRow) {
185185

186186
Object[][] data = null;
187187
try {
@@ -223,7 +223,7 @@ public static Object[][] getDataHashTable(String excelPath, String sheetName, in
223223
return data;
224224
}
225225

226-
public static String getTestCaseName(String sTestCase) throws Exception {
226+
public String getTestCaseName(String sTestCase) throws Exception {
227227
String value = sTestCase;
228228
try {
229229
int posi = value.indexOf("@");
@@ -238,7 +238,7 @@ public static String getTestCaseName(String sTestCase) throws Exception {
238238
}
239239
}
240240

241-
public static int getRowContains(String sTestCaseName, int colNum) throws Exception {
241+
public int getRowContains(String sTestCaseName, int colNum) throws Exception {
242242
int i;
243243
try {
244244
int rowCount = getRowUsed();
@@ -255,7 +255,7 @@ public static int getRowContains(String sTestCaseName, int colNum) throws Except
255255

256256
}
257257

258-
public static int getRowUsed() throws Exception {
258+
public int getRowUsed() throws Exception {
259259
try {
260260
int RowCount = sh.getLastRowNum();
261261
return RowCount;
@@ -266,7 +266,7 @@ public static int getRowUsed() throws Exception {
266266
}
267267

268268
// Get cell data
269-
public static String getCellData(int rownum, int colnum) {
269+
public String getCellData(int rownum, int colnum) {
270270
try {
271271
cell = sh.getRow(rownum).getCell(colnum);
272272
String CellData = null;
@@ -294,27 +294,27 @@ public static String getCellData(int rownum, int colnum) {
294294
}
295295
}
296296

297-
public static String getCellData(int rowNum, String columnName) {
297+
public String getCellData(int rowNum, String columnName) {
298298
return getCellData(rowNum, columns.get(columnName));
299299
}
300300

301-
public static int getRows() {
301+
public int getRows() {
302302
return sh.getPhysicalNumberOfRows();
303303
}
304304

305-
public static int getRowCount() {
305+
public int getRowCount() {
306306
int rowCount = sh.getLastRowNum() + 1;
307307
return rowCount;
308308
}
309309

310-
public static int getColumnCount() {
310+
public int getColumnCount() {
311311
row = sh.getRow(0);
312312
int colCount = row.getLastCellNum();
313313
return colCount;
314314
}
315315

316316
// Write data to excel sheet
317-
public static void setCellData(String text, int rowNumber, int colNumber) {
317+
public void setCellData(String text, int rowNumber, int colNumber) {
318318
try {
319319
row = sh.getRow(rowNumber);
320320
if (row == null) {
@@ -348,7 +348,7 @@ public static void setCellData(String text, int rowNumber, int colNumber) {
348348
}
349349
}
350350

351-
public static void setCellData(String text, int rowNum, String columnName) {
351+
public void setCellData(String text, int rowNum, String columnName) {
352352
try {
353353
row = sh.getRow(rowNum);
354354
if (row == null) {

src/main/java/anhtester/com/utils/ZipUtils.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@
66
package anhtester.com.utils;
77

88
import org.zeroturnaround.zip.ZipUtil;
9+
910
import java.io.File;
10-
import static anhtester.com.constants.FrameworkConstants.*;
11+
12+
import static anhtester.com.constants.FrameworkConstants.EXTENT_REPORT_FOLDER_PATH;
13+
import static anhtester.com.constants.FrameworkConstants.Zipped_ExtentReports_Folder_Name;
1114

1215
public class ZipUtils {
1316

14-
/* make Zip file of Extent Reports in Project Root folder */
17+
/* Make Zip file of Extent Reports in Project Root folder */
1518
public static void zip() {
1619

17-
ZipUtil.pack(new File(EXTENT_REPORT_FOLDER_PATH),
18-
new File(Zipped_ExtentReports_Folder_Name));
20+
ZipUtil.pack(new File(EXTENT_REPORT_FOLDER_PATH), new File(Zipped_ExtentReports_Folder_Name));
1921

20-
Log.info("Zipped ExtentReports folder successfuly");
22+
Log.info("Zipped " + Zipped_ExtentReports_Folder_Name + " folder successfully !!");
2123
}
2224

2325
}

src/test/java/anhtester/com/common/BaseTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public class BaseTest {
1919
public void beforeSuite() {
2020
AllureManager.setAllureEnvironmentInformation();
2121
PropertiesHelpers.loadAllFiles(); //Config and Locators
22-
ExcelHelpers.setExcelFile(FrameworkConstants.EXCEL_DATA_PATH, "SignIn");
2322
}
2423

2524
@Parameters("browser")

src/test/java/anhtester/com/projects/website/crm/dataprovider/DataProviderManager.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,24 @@ public void testGetClientData(Hashtable<String, String> data) {
4343

4444
@DataProvider(name = "getSignInDataHashTable")
4545
public static Object[][] getSignInData() {
46-
Object[][] data = ExcelHelpers.getDataHashTable(Helpers.getCurrentDir() + FrameworkConstants.EXCEL_DATA_PATH, "SignIn", 1, 2);
46+
ExcelHelpers excelHelpers = new ExcelHelpers();
47+
Object[][] data = excelHelpers.getDataHashTable(Helpers.getCurrentDir() + FrameworkConstants.EXCEL_DATA_PATH, "SignIn", 1, 2);
48+
System.out.println("getSignInData: " + data);
49+
return data;
50+
}
51+
52+
@DataProvider(name = "getSignInDataHashTable2")
53+
public static Object[][] getSignInData2() {
54+
ExcelHelpers excelHelpers = new ExcelHelpers();
55+
Object[][] data = excelHelpers.getDataHashTable(Helpers.getCurrentDir() + FrameworkConstants.EXCEL_DATA_PATH, "SignIn", 2, 3);
4756
System.out.println("getSignInData: " + data);
4857
return data;
4958
}
5059

5160
@DataProvider(name = "getClientDataHashTable", parallel = true)
5261
public static Object[][] getClientData() {
53-
Object[][] data = ExcelHelpers.getDataHashTable(Helpers.getCurrentDir() + FrameworkConstants.EXCEL_DATA_PATH, "Client", 1, 3);
62+
ExcelHelpers excelHelpers = new ExcelHelpers();
63+
Object[][] data = excelHelpers.getDataHashTable(Helpers.getCurrentDir() + FrameworkConstants.EXCEL_DATA_PATH, "Client", 1, 4);
5464
System.out.println("getClientData: " + data);
5565
return data;
5666
}

src/test/java/anhtester/com/projects/website/crm/pages/SignIn/SignInPage.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import anhtester.com.constants.FrameworkConstants;
44
import anhtester.com.helpers.ExcelHelpers;
55
import anhtester.com.projects.website.crm.models.SignInModel;
6+
import anhtester.com.projects.website.crm.pages.Dashboard.DashboardPage;
67
import anhtester.com.utils.DecodeUtils;
78
import anhtester.com.utils.ObjectUtils;
89
import anhtester.com.utils.WebUI;
9-
import anhtester.com.projects.website.crm.pages.Dashboard.DashboardPage;
1010
import org.testng.Assert;
1111

1212
import java.util.Hashtable;
@@ -22,12 +22,13 @@ public SignInPage() {
2222
}
2323

2424
public DashboardPage signInWithAdminRole() {
25-
ExcelHelpers.setExcelFile(FrameworkConstants.EXCEL_DATA_PATH, "SignIn");
25+
ExcelHelpers excelHelpers = new ExcelHelpers();
26+
excelHelpers.setExcelFile(FrameworkConstants.EXCEL_DATA_PATH, "SignIn");
2627
WebUI.getToUrl(FrameworkConstants.BASE_URL);
2728
Assert.assertTrue(WebUI.verifyPageUrl(pageUrl), "The url of sign in page not match.");
2829
Assert.assertTrue(WebUI.verifyPageTitle(pageTitle), "The title of sign in page not match.");
29-
WebUI.setText(ObjectUtils.getObject("inputEmail"), ExcelHelpers.getCellData(1, SignInModel.getEmail()));
30-
WebUI.setText(ObjectUtils.getObject("inputPassword"), DecodeUtils.decrypt(ExcelHelpers.getCellData(1, SignInModel.getPassword())));
30+
WebUI.setText(ObjectUtils.getObject("inputEmail"), excelHelpers.getCellData(1, SignInModel.getEmail()));
31+
WebUI.setText(ObjectUtils.getObject("inputPassword"), DecodeUtils.decrypt(excelHelpers.getCellData(1, SignInModel.getPassword())));
3132
WebUI.clickElement(ObjectUtils.getObject("buttonSignIn"));
3233
WebUI.waitForPageLoaded();
3334
Assert.assertTrue(WebUI.verifyPageUrl(dashboardPageURL), "Sign in failed. Can not redirect to Dashboard page.");
@@ -37,12 +38,13 @@ public DashboardPage signInWithAdminRole() {
3738
}
3839

3940
public DashboardPage signInWithTeamLeaderRole() {
40-
ExcelHelpers.setExcelFile(FrameworkConstants.EXCEL_DATA_PATH, "SignIn");
41+
ExcelHelpers excelHelpers = new ExcelHelpers();
42+
excelHelpers.setExcelFile(FrameworkConstants.EXCEL_DATA_PATH, "SignIn");
4143
WebUI.getToUrl(FrameworkConstants.BASE_URL);
4244
Assert.assertTrue(WebUI.verifyPageUrl(pageUrl), "The url of sign in page not match.");
4345
Assert.assertTrue(WebUI.verifyPageTitle(pageTitle), "The title of sign in page not match.");
44-
WebUI.setText(ObjectUtils.getObject("inputEmail"), ExcelHelpers.getCellData(2, SignInModel.getEmail()));
45-
WebUI.setText(ObjectUtils.getObject("inputPassword"), DecodeUtils.decrypt(ExcelHelpers.getCellData(2, SignInModel.getPassword())));
46+
WebUI.setText(ObjectUtils.getObject("inputEmail"), excelHelpers.getCellData(2, SignInModel.getEmail()));
47+
WebUI.setText(ObjectUtils.getObject("inputPassword"), DecodeUtils.decrypt(excelHelpers.getCellData(2, SignInModel.getPassword())));
4648
WebUI.clickElement(ObjectUtils.getObject("buttonSignIn"));
4749
WebUI.waitForPageLoaded();
4850
Assert.assertTrue(WebUI.verifyPageUrl(dashboardPageURL), "Sign in failed. Can not redirect to Dashboard page.");
@@ -52,12 +54,13 @@ public DashboardPage signInWithTeamLeaderRole() {
5254
}
5355

5456
public DashboardPage signInWithTeamMemberRole() {
55-
ExcelHelpers.setExcelFile(FrameworkConstants.EXCEL_DATA_PATH, "SignIn");
57+
ExcelHelpers excelHelpers = new ExcelHelpers();
58+
excelHelpers.setExcelFile(FrameworkConstants.EXCEL_DATA_PATH, "SignIn");
5659
WebUI.getToUrl(FrameworkConstants.BASE_URL);
5760
Assert.assertTrue(WebUI.verifyPageUrl(pageUrl), "The url of sign in page not match.");
5861
Assert.assertTrue(WebUI.verifyPageTitle(pageTitle), "The title of sign in page not match.");
59-
WebUI.setText(ObjectUtils.getObject("inputEmail"), ExcelHelpers.getCellData(3, SignInModel.getEmail()));
60-
WebUI.setText(ObjectUtils.getObject("inputPassword"), DecodeUtils.decrypt(ExcelHelpers.getCellData(3, SignInModel.getPassword())));
62+
WebUI.setText(ObjectUtils.getObject("inputEmail"), excelHelpers.getCellData(3, SignInModel.getEmail()));
63+
WebUI.setText(ObjectUtils.getObject("inputPassword"), DecodeUtils.decrypt(excelHelpers.getCellData(3, SignInModel.getPassword())));
6164
WebUI.clickElement(ObjectUtils.getObject("buttonSignIn"));
6265
WebUI.waitForPageLoaded();
6366
Assert.assertTrue(WebUI.verifyPageUrl(dashboardPageURL), "Sign in failed. Can not redirect to Dashboard page.");

0 commit comments

Comments
 (0)