Skip to content

Commit f1f9972

Browse files
committed
Update test cases
1 parent 896d243 commit f1f9972

File tree

6 files changed

+42
-23
lines changed

6 files changed

+42
-23
lines changed

pom.xml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,13 @@
5353
<jackson.version>2.21.1</jackson.version>
5454

5555
<!-- Suite XML path - CRM -->
56-
<suite.signin.simple>src/test/resources/suites/SignIn-simple.xml</suite.signin.simple>
57-
<suite.signin.parallel>src/test/resources/suites/SignIn-parallel-methods.xml</suite.signin.parallel>
58-
<suite.client.parallel>src/test/resources/suites/Clients-parallel.xml</suite.client.parallel>
59-
<suite.client.simple>src/test/resources/suites/Clients-simple.xml</suite.client.simple>
56+
<suite.signin.simple>src/test/resources/suites/CRM/SignIn-simple.xml</suite.signin.simple>
57+
<suite.signin.parallel>src/test/resources/suites/CRM/SignIn-parallel-methods.xml</suite.signin.parallel>
58+
<suite.client.parallel>src/test/resources/suites/CRM/Clients-parallel.xml</suite.client.parallel>
59+
<suite.client.simple>src/test/resources/suites/CRM/Clients-simple.xml</suite.client.simple>
6060
<!-- Suite XML path - CMS -->
6161
<suite.login>src/test/resources/suites/CMS/LoginTestCMS.xml</suite.login>
62+
<suite.addproduct>src/test/resources/suites/CMS/AddProductCMS.xml</suite.addproduct>
6263
<suite.order>src/test/resources/suites/CMS/OrderProductCMS.xml</suite.order>
6364
<!-- Suite XML path - ALL -->
6465
<suite.all>src/test/resources/suites/SuiteAll.xml</suite.all>
@@ -431,7 +432,7 @@
431432
<plugin>
432433
<groupId>org.apache.maven.plugins</groupId>
433434
<artifactId>maven-compiler-plugin</artifactId>
434-
<version>3.14.1</version>
435+
<version>3.15.0</version>
435436
<configuration>
436437
<source>${java-compiler.version}</source>
437438
<target>${java-compiler.version}</target>
@@ -444,8 +445,9 @@
444445
<version>${maven-surefire-plugin.version}</version>
445446
<configuration>
446447
<suiteXmlFiles>
447-
<!--<suiteXmlFile>${suite.all}</suiteXmlFile>-->
448-
<suiteXmlFile>src/test/resources/suites/CMS/LoginTestCMS.xml</suiteXmlFile>
448+
<suiteXmlFile>${suite.signin.parallel}</suiteXmlFile>
449+
<suiteXmlFile>${suite.addproduct}</suiteXmlFile>
450+
<suiteXmlFile>${suite.order}</suiteXmlFile>
449451
</suiteXmlFiles>
450452
<argLine>
451453
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectjweaver.version}/aspectjweaver-${aspectjweaver.version}.jar"
@@ -462,17 +464,17 @@
462464
<artifactId>allure-maven</artifactId>
463465
<version>${allure-maven.version}</version>
464466
<configuration>
465-
<reportVersion>2.35.1</reportVersion>
467+
<reportVersion>${allure-plugin-api.version}</reportVersion>
466468
<allureDownloadUrl>
467-
${allure.cmd.download.url}/2.35.1/allure-commandline-2.35.1.zip
469+
${allure.cmd.download.url}/${allure-plugin-api.version}/allure-commandline-${allure-plugin-api.version}.zip
468470
</allureDownloadUrl>
469471
</configuration>
470472
</plugin>
471473

472474
<plugin>
473475
<groupId>org.apache.maven.plugins</groupId>
474476
<artifactId>maven-javadoc-plugin</artifactId>
475-
<version>3.6.3</version>
477+
<version>3.12.0</version>
476478
<configuration>
477479
<source>${java-compiler.version}</source>
478480
<encoding>UTF-8</encoding>

src/test/java/com/anhtester/projects/cms/admin/pages/logins/LoginPageCMS.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
import com.anhtester.helpers.PropertiesHelpers;
55
import com.anhtester.projects.cms.CommonPageCMS;
66
import com.anhtester.projects.cms.users.pages.dashboard.DashboardPage;
7+
8+
import io.qameta.allure.Step;
9+
710
import org.openqa.selenium.By;
811

912
import static com.anhtester.keywords.WebUI.*;
@@ -16,7 +19,8 @@ public class LoginPageCMS extends CommonPageCMS {
1619
private By buttonCopyAdminAcc = By.xpath("//button[normalize-space()='Copy']");
1720
private By buttonSubmitLogin = By.xpath("//button[normalize-space()='Login']");
1821
private By titleLoginPage = By.xpath("//h1[normalize-space() = 'Login to your account.']");
19-
private By messageRequiredEmail = By.xpath("//strong[contains(text(),'The email field is required when phone is not present.')]");
22+
private By messageRequiredEmail = By
23+
.xpath("//strong[contains(text(),'The email field is required when phone is not present.')]");
2024
private By inputEmail = By.xpath("//input[@id='email']");
2125
private By inputPassword = By.xpath("//input[@id='password']");
2226
private By messageAccDoesNotExist = By.xpath("//span[@data-notify='message']");
@@ -27,6 +31,7 @@ public void clickCloseAdvertisementPopup() {
2731
clickElement(closeAdvertisementPopup);
2832
}
2933

34+
@Step("Open login page")
3035
public void openLoginPage() {
3136
openWebsite(FrameworkConstants.URL_CMS_USER);
3237
clickElement(closeAdvertisementPopup);
@@ -36,6 +41,7 @@ public void openLoginPage() {
3641
verifyElementVisible(titleLoginPage, "Login page is NOT displayed");
3742
}
3843

44+
@Step("Verify redirect to Admin page")
3945
public void verifyRedirectToAdminPage() {
4046
verifyElementVisible(avatarProfile, "Can not redirect to Admin page.");
4147
}
@@ -46,7 +52,8 @@ public void loginFailWithEmailNull() {
4652
clickElement(buttonSubmitLogin);
4753
waitForPageLoaded();
4854
sleep(1);
49-
verifyEquals(getTextElement(messageRequiredEmail).trim(), "The email field is required when phone is not present.", "");
55+
verifyEquals(getTextElement(messageRequiredEmail).trim(),
56+
"The email field is required when phone is not present.", "");
5057
}
5158

5259
public void loginFailWithEmailDoesNotExist(String email, String password) {
@@ -82,6 +89,7 @@ public void loginFailWithIncorrectPassword(String email, String password) {
8289
verifyElementVisible(messageAccDoesNotExist, "Password is failed but valid is NOT displayed.");
8390
}
8491

92+
@Step("Login with Customer account")
8593
public void loginSuccessWithCustomerAccount(String email, String password) {
8694
openLoginPage();
8795
sleep(2);
@@ -95,25 +103,23 @@ public void loginSuccessWithCustomerAccount(String email, String password) {
95103
verifyElementVisible(DashboardPage.titleDashboard, "Dashboard page is NOT displayed.");
96104
}
97105

106+
@Step("Login with Admin account")
98107
public CommonPageCMS loginSuccessAdminPage(String email, String password) {
99108
openWebsite(FrameworkConstants.URL_CMS_ADMIN);
100109
setText(inputEmail, email);
101110
setText(inputPassword, password);
102111
clickElement(buttonSubmitLogin);
103-
waitForElementVisible(titleAnhTesterAdminPage);
104112
verifyElementVisible(titleAnhTesterAdminPage, "Admin page is NOT displayed.");
105113
return new CommonPageCMS();
106114
}
107115

116+
@Step("Login with email and password from properties file")
108117
public CommonPageCMS loginSuccessAdminPage() {
109118
openWebsite(FrameworkConstants.URL_CMS_ADMIN);
110119
setText(inputEmail, PropertiesHelpers.getValue("email"));
111120
setText(inputPassword, PropertiesHelpers.getValue("password"));
112121
clickElement(buttonSubmitLogin);
113-
waitForElementVisible(titleAnhTesterAdminPage);
114122
verifyElementVisible(titleAnhTesterAdminPage, "Admin page is NOT displayed.");
115123
return new CommonPageCMS();
116124
}
117125
}
118-
119-

src/test/java/com/anhtester/projects/cms/users/pages/products/ProductInfoPageCMS.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
public class ProductInfoPageCMS extends CommonPageCMS {
1212
private By productName = By.xpath("//h1");
13-
public static By productPrice = By.xpath("(//div[text()='Discount Price:']/parent::div)/following-sibling::div//strong");
13+
public static By productPrice = By.xpath("(//div[text()='Price:']/parent::div)/following-sibling::div//strong");
1414
private By productUnit = By.xpath("//span[@class='opacity-70']");
1515
private By productDescription = By.xpath("//div[@class = 'mw-100 overflow-auto text-left aiz-editor-data']/p");
1616
private By selectProductName = By.xpath("(//div[contains(@class,'product-name')])[1]");

src/test/java/com/anhtester/projects/crm/pages/SignIn/SignInPageCRM.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
import com.anhtester.projects.crm.models.SignInModel;
1010
import com.anhtester.projects.crm.pages.Dashboard.DashboardPageCRM;
1111
import com.anhtester.utils.DecodeUtils;
12+
13+
import io.qameta.allure.Step;
14+
1215
import org.openqa.selenium.By;
1316

1417
import java.util.Hashtable;
@@ -30,6 +33,7 @@ public class SignInPageCRM extends CommonPageCRM {
3033
public SignInPageCRM() {
3134
}
3235

36+
@Step("Sign in with Admin Role")
3337
public DashboardPageCRM signInWithAdminRole() {
3438
ExcelHelpers excelHelpers = new ExcelHelpers();
3539
excelHelpers.setExcelFile(FrameworkConstants.EXCEL_DATA_FILE_PATH, "SignIn");
@@ -42,11 +46,13 @@ public DashboardPageCRM signInWithAdminRole() {
4246
setText(inputPassword, DecodeUtils.decrypt(excelHelpers.getCellData(1, SignInModel.getPassword())));
4347
clickElement(buttonSignIn);
4448
waitForPageLoaded();
45-
verifyContains(getCurrentUrl(), getDashboardPage().pageUrl, "Sign in failed. Can not redirect to Dashboard page.");
49+
verifyContains(getCurrentUrl(), getDashboardPage().pageUrl,
50+
"Sign in failed. Can not redirect to Dashboard page.");
4651

4752
return new DashboardPageCRM();
4853
}
4954

55+
@Step("Sign in with Client Role")
5056
public DashboardPageCRM signInWithClientRole() {
5157
ExcelHelpers excelHelpers = new ExcelHelpers();
5258
excelHelpers.setExcelFile(FrameworkConstants.EXCEL_DATA_FILE_PATH, "SignIn");
@@ -59,11 +65,13 @@ public DashboardPageCRM signInWithClientRole() {
5965
setText(inputPassword, DecodeUtils.decrypt(excelHelpers.getCellData(2, SignInModel.getPassword())));
6066
clickElement(buttonSignIn);
6167
waitForPageLoaded();
62-
verifyContains(getCurrentUrl(), getDashboardPage().pageUrl, "Sign in failed. Can not redirect to Dashboard page.");
68+
verifyContains(getCurrentUrl(), getDashboardPage().pageUrl,
69+
"Sign in failed. Can not redirect to Dashboard page.");
6370

6471
return new DashboardPageCRM();
6572
}
6673

74+
@Step("Sign in with email and password")
6775
public DashboardPageCRM signIn(String email, String password) {
6876
openWebsite(FrameworkConstants.URL_CRM);
6977
verifyContains(getCurrentUrl(), pageUrl, "The url of sign in page not match.");
@@ -74,11 +82,13 @@ public DashboardPageCRM signIn(String email, String password) {
7482
setText(inputPassword, password);
7583
clickElement(buttonSignIn);
7684
waitForPageLoaded();
77-
verifyContains(getCurrentUrl(), getDashboardPage().pageUrl, "Sign in failed. Can not redirect to Dashboard page.");
85+
verifyContains(getCurrentUrl(), getDashboardPage().pageUrl,
86+
"Sign in failed. Can not redirect to Dashboard page.");
7887

7988
return new DashboardPageCRM();
8089
}
8190

91+
@Step("Sign in with data")
8292
public DashboardPageCRM signIn(Hashtable<String, String> data) {
8393
openWebsite(FrameworkConstants.URL_CRM);
8494
verifyContains(getCurrentUrl(), pageUrl, "The url of sign in page not match.");
@@ -89,7 +99,8 @@ public DashboardPageCRM signIn(Hashtable<String, String> data) {
8999
setText(inputPassword, DecodeUtils.decrypt(data.get(SignInModel.getPassword())));
90100
clickElement(buttonSignIn);
91101
waitForPageLoaded();
92-
verifyContains(getCurrentUrl(), getDashboardPage().pageUrl, "Sign in failed. Can not redirect to Dashboard page.");
102+
verifyContains(getCurrentUrl(), getDashboardPage().pageUrl,
103+
"Sign in failed. Can not redirect to Dashboard page.");
93104

94105
return new DashboardPageCRM();
95106
}

src/test/resources/config/data.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ EXCEL_CMS_DATA = src/test/resources/testdataCMS/CMS_DATA.xlsx
1111
EXCEL_CMS_PRODUCTS_USER = src/test/resources/testdataCMS/GetProductInfo.xlsx
1212
email=admin@example.com
1313
password=123456
14-
product_P01=Gio qua Tet hquHA
15-
product_P02=Adobe Premiere Elements 2022
14+
product_P01=Giỏ quà Tết iMqku
15+
product_P02=Cosy Hai Yen OXUOCYJB
-166 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)