Skip to content

Commit 742dada

Browse files
committed
Update version 1.9.7
1 parent 9b944cd commit 742dada

34 files changed

+285
-215
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ logs/
88
target/
99
test-output/
1010
reports/
11-
*.png
12-
*.jpg
1311
*.mp4
1412
*.avi
1513
*.zip

CHANGELOG.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
v1.9.7
2+
======
3+
Sep 4, 2023
4+
* Update Selenium 4.12.0
5+
* Support Chrome browser 116
6+
17
v1.9.6
28
======
39
Aug 1, 2023

pom.xml

Lines changed: 142 additions & 139 deletions
Large diffs are not rendered by default.

src/main/java/anhtester/com/report/ExtentReportManager.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,15 @@ public static void flushReports() {
7373
}
7474

7575
public static void createTest(String testCaseName) {
76-
// ExtentManager.setExtentTest(extent.createTest(testCaseName));
77-
ExtentTestManager.setExtentTest(extentReports.createTest(IconUtils.getBrowserIcon() + " : " + testCaseName));
76+
ExtentTestManager.setExtentTest(extentReports.createTest(IconUtils.getBrowserIcon() + " " + testCaseName));
77+
//ExtentTestManager.setExtentTest(extentReports.createTest(testCaseName));
7878
}
7979

8080
public static void createTest(String testCaseName, String description) {
81-
// ExtentManager.setExtentTest(extent.createTest(testCaseName));
8281
ExtentTestManager.setExtentTest(extentReports.createTest(testCaseName, description));
8382
}
8483

8584
public static void removeTest(String testCaseName) {
86-
// ExtentManager.setExtentTest(extent.createTest(testCaseName));
8785
extentReports.removeTest(testCaseName);
8886
}
8987

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
public class BaseTest extends CommonPageCMS {
1414

1515
@Parameters("BROWSER")
16-
@BeforeMethod(alwaysRun = true)
16+
@BeforeMethod
1717
public void createDriver(@Optional("chrome") String browser) {
1818
System.setProperty("webdriver.http.factory", "jdk-http-client");
1919
WebDriver driver = ThreadGuard.protect(new TargetFactory().createInstance(browser));

src/test/java/anhtester/com/dataprovider/DataProviderAddProduct.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class DataProviderAddProduct {
99
@DataProvider(name = "data_provider_add_product")
1010
public Object[][] dataAddProduct() {
1111
ExcelHelpers excelHelpers = new ExcelHelpers();
12-
Object[][] data = excelHelpers.getDataHashTable(Helpers.getCurrentDir() + FrameworkConstants.EXCEL_CMS_DATA, "AddProduct", 1, 1);
12+
Object[][] data = excelHelpers.getDataHashTable(Helpers.getCurrentDir() + FrameworkConstants.EXCEL_CMS_DATA, "AddProduct", 2, 2);
1313
return data;
1414
}
1515
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package anhtester.com.projects;
2+
3+
import org.testng.annotations.Test;
4+
5+
public class App {
6+
public static void main(String[] args) {
7+
System.out.println("Build success !!");
8+
}
9+
}

src/test/java/anhtester/com/projects/cms/CommonPageCMS.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public ProductInfoPageCMS getProductInfoPage() {
6868
private By buttonSave = By.xpath("//button[normalize-space()='Save']");
6969
private By inputSearch = By.xpath("//input[@id='search']");
7070
public By avatarProfile = By.xpath("//span[contains(@class,'avatar avatar-sm')]");
71+
public By buttonCookies = By.xpath("//button[normalize-space()='Ok. I Understood']");
7172

7273

7374
public void enterDataOnSearchDataTable(String value) {

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
import org.openqa.selenium.By;
88

99
import static anhtester.com.keywords.WebUI.*;
10+
import static anhtester.com.keywords.WebUI.clickElement;
1011

1112
public class LoginPageCMS extends CommonPageCMS {
1213

13-
private By closeAdvertisementPopup = By.xpath("//i[@class='la la-close fs-20']");
14+
private By closeAdvertisementPopup = By.xpath("//button[@data-key='website-popup']");
1415
private By buttonLogin = By.xpath("(//a[normalize-space()='Registration']/parent::li)/preceding-sibling::li");
1516
private By buttonCopyAdminAcc = By.xpath("//button[normalize-space()='Copy']");
1617
private By buttonSubmitLogin = By.xpath("//button[normalize-space()='Login']");
@@ -28,17 +29,20 @@ public void clickCloseAdvertisementPopup() {
2829

2930
public void openLoginPage() {
3031
openURL(FrameworkConstants.URL_CMS_USER);
31-
clickCloseAdvertisementPopup();
32+
clickElement(closeAdvertisementPopup);
33+
clickElement(buttonCookies);
3234
clickElement(buttonLogin);
35+
waitForPageLoaded();
3336
verifyElementVisible(titleLoginPage, "Login page is NOT displayed");
3437
}
3538

3639
public void verifyRedirectToAdminPage() {
3740
verifyElementVisible(avatarProfile, "Can not redirect to Admin page.");
3841
}
3942

40-
public void loginFailWithNullEmail() {
43+
public void loginFailWithEmailNull() {
4144
openLoginPage();
45+
waitForPageLoaded();
4246
clickElement(buttonSubmitLogin);
4347
verifyEquals(getTextElement(messageRequiredEmail).trim(), "The email field is required when phone is not present.", "");
4448
}
@@ -48,14 +52,17 @@ public void loginFailWithEmailDoesNotExist(String email, String password) {
4852
setText(inputEmail, email);
4953
setText(inputPassword, password);
5054
clickElement(buttonSubmitLogin);
55+
waitForPageLoaded();
5156
verifyElementVisible(messageAccDoesNotExist, "Email is incorrect but valid is NOT displayed.");
5257
}
5358

5459
public void loginFailWithNullPassword(String email) {
5560
openLoginPage();
5661
setText(inputEmail, email);
5762
clickElement(buttonSubmitLogin);
58-
verifyElementVisible(messageRequiredPassword, "Password is NULL but valid is NOT displayed.");
63+
waitForPageLoaded();
64+
sleep(1);
65+
verifyElementPresent(messageRequiredPassword, "No warning password input");
5966
}
6067

6168
public void loginFailWithIncorrectPassword(String email, String password) {
@@ -73,6 +80,7 @@ public void loginSuccessWithCustomerAccount(String email, String password) {
7380
clearText(inputPassword);
7481
setText(inputPassword, password);
7582
clickElement(buttonSubmitLogin);
83+
waitForPageLoaded();
7684
waitForElementVisible(DashboardPage.titleDashboard);
7785
verifyElementVisible(DashboardPage.titleDashboard, "Dashboard page is NOT displayed.");
7886
}

src/test/java/anhtester/com/projects/cms/admin/pages/products/AddProductPage.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package anhtester.com.projects.cms.admin.pages.products;
22

3+
import anhtester.com.driver.DriverManager;
34
import anhtester.com.helpers.Helpers;
45
import anhtester.com.keywords.WebUI;
56
import anhtester.com.projects.cms.CommonPageCMS;
@@ -28,6 +29,7 @@ public class AddProductPage extends CommonPageCMS {
2829
private By selectChooseThumbnailImgs = By.xpath("//label[contains(text(),'Thumbnail Image')]/following-sibling::div//div[contains(text(),'Choose File')]");
2930
private By uploadNewImageTab = By.xpath("//a[normalize-space()='Upload New']");
3031
private By buttonBrowseImages = By.xpath("//button[normalize-space()='Browse']");
32+
private By inputGalleryImages = By.xpath("//input[@class = 'uppy-Dashboard-input']");
3133
private By buttonAddFileImgs = By.xpath("//button[normalize-space()='Add Files']");
3234
private By selectFileTab = By.xpath("//a[normalize-space()='Select File']");
3335
private By selectGalleryImages = By.xpath("(//img[@class='img-fit'])[1]");
@@ -51,6 +53,7 @@ public class AddProductPage extends CommonPageCMS {
5153
private By allCategoriesTabUI = By.xpath("//a[normalize-space()='All categories']");
5254
private By unitUI = By.xpath("//span[@class='opacity-70']");
5355
private By descriptionUI = By.xpath("//div[@class = 'mw-100 overflow-auto text-left aiz-editor-data']//p");
56+
5457
int randomNumber = new Random().nextInt(1000000);
5558
private By menuAllProducts = By.xpath("//span[normalize-space()='All products']");
5659
private By newProduct = By.xpath("(//span[@class='text-muted text-truncate-2'])[1]");
@@ -76,20 +79,22 @@ public void addProduct(String productName, String category, String unit, String
7679
WebUI.clickElement(selectChooseGalleryImgs);
7780
WebUI.clickElement(uploadNewImageTab);
7881
//Upload images Gallery with Form
79-
WebUI.uploadFileWithLocalForm(buttonBrowseImages, Helpers.getCurrentDir() + "src\\test\\resources\\testdataCMS\\" + imgName);
82+
//WebUI.uploadFileWithLocalForm(buttonBrowseImages, Helpers.getCurrentDir() + "src\\test\\resources\\testdataCMS\\" + imgName);
83+
//Upload images Gallery with sendKeys
84+
DriverManager.getDriver().findElement(inputGalleryImages).sendKeys(Helpers.getCurrentDir() + "src\\test\\resources\\testdataCMS\\" + imgName);
8085
WebUI.clickElement(selectFileTab);
8186
LogUtils.info(imgName);
8287
LogUtils.info(Helpers.splitString(imgName, "[.]"));
83-
String nameImage = Helpers.splitString(imgName, "[.]").get(0);
88+
String imageName = Helpers.splitString(imgName, "[.]").get(0);
8489
//Search and select images
85-
WebUI.setText(inputSearchImg, nameImage, Keys.ENTER);
90+
WebUI.setText(inputSearchImg, imageName, Keys.ENTER);
8691
WebUI.waitForJQueryLoad();
8792
WebUI.sleep(2);
8893
WebUI.clickElementWithJs(selectGalleryImages);
8994
WebUI.clickElement(buttonAddFileImgs);
9095
WebUI.waitForPageLoaded();
9196
WebUI.clickElement(selectChooseThumbnailImgs);
92-
WebUI.setText(inputSearchImg, nameImage, Keys.ENTER);
97+
WebUI.setText(inputSearchImg, imageName, Keys.ENTER);
9398
WebUI.waitForJQueryLoad();
9499
WebUI.sleep(2);
95100
WebUI.clickElementWithJs(selectThumbnailImages);
@@ -108,7 +113,7 @@ public void addProduct(String productName, String category, String unit, String
108113
WebUI.setText(inputMetaTitle, productName);
109114
WebUI.setText(inputDescription, description);
110115
WebUI.clickElement(selectChooseMetaImage);
111-
WebUI.setText(inputSearchImg, nameImage, Keys.ENTER);
116+
WebUI.setText(inputSearchImg, imageName, Keys.ENTER);
112117
WebUI.waitForJQueryLoad();
113118
WebUI.sleep(2);
114119
WebUI.clickElementWithJs(selectThumbnailImages);
@@ -133,16 +138,18 @@ public void verifyNewProduct(String category, String unit, Double unitPrice, Str
133138
WebUI.switchToWindowOrTabByTitle(nameProductVerify);
134139
getLoginPageCMS().clickCloseAdvertisementPopup();
135140
WebUI.waitForPageLoaded();
141+
WebUI.sleep(2);
136142
WebUI.verifyEquals(WebUI.getTextElement(By.xpath("//h1[normalize-space()='" + nameProductVerify + "']")).trim(), nameProductVerify, "Product name displayed wrong");
137143
WebUI.verifyEquals(WebUI.getTextElement(unitUI).trim(), "/" + unit, "Unit displayed wrong");
138-
WebUI.scrollToElementToTop(descriptionUI);
144+
WebUI.scrollToElementToBottom(descriptionUI);
139145
WebUI.verifyEquals(WebUI.getTextElement(descriptionUI).trim(), description, "Description displayed wrong");
146+
WebUI.sleep(2);
140147
//Check Product in Category
141148
WebUI.clickElement(allCategoriesTabUI);
142149
WebUI.waitForPageLoaded();
143150
WebUI.clickElement(By.xpath("//a[contains(text(),'" + category + "')]"));
151+
WebUI.waitForPageLoaded();
152+
WebUI.sleep(2);
144153
WebUI.verifyElementVisible(By.xpath("(//a[normalize-space()='" + nameProductVerify + "'])"), "Product is NOT displayed in Category");
145-
WebUI.closeCurrentWindow();
146-
WebUI.switchToMainWindow();
147154
}
148155
}

0 commit comments

Comments
 (0)