Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/com/cutanddry/qa/functions/Customer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3298,6 +3298,9 @@ public static void clickCatalogListViewSort(String sort)throws InterruptedExcept
public static boolean areFirstThreeItemCodesSortedAscending() {
return customersPage.areFirstThreeItemCodesSortedAscending();
}
public static boolean areFirstThreeItemCodesSortedDescending() {
return customersPage.areFirstThreeItemCodesSortedDescending();
}
public static boolean areFirstFiveItemNamesSortedAscending(String column) {
return customersPage.areFirstFiveItemNamesSortedAscending(column);
}
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/cutanddry/qa/pages/CustomersPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -5468,6 +5468,23 @@ public boolean areFirstThreeItemCodesSortedAscending() {
}
return true;
}
public boolean areFirstThreeItemCodesSortedDescending() {
List<WebElement> itemCodeElements = driver.findElements(catalogListViewItemCode);
List<Integer> itemCodes = new ArrayList<>();
int limit = Math.min(3, itemCodeElements.size());
for (int i = 0; i < limit; i++) {
String codeText = itemCodeElements.get(i).getText().trim();
if (!codeText.isEmpty()) {
itemCodes.add(Integer.parseInt(codeText));
}
}
for (int i = 0; i < itemCodes.size() - 1; i++) {
if (itemCodes.get(i) < itemCodes.get(i + 1)) {
return false;
}
}
return true;
}
public boolean areFirstFiveItemNamesSortedAscending(String column) {
List<WebElement> itemNameElements = driver.findElements(By.xpath(catalogListViewItemName.replace("COLUMN",column)));
List<String> itemNames = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.cutanddry.qa.tests.catalog;

import com.cutanddry.qa.base.TestBase;
import com.cutanddry.qa.data.models.User;
import com.cutanddry.qa.functions.Customer;
import com.cutanddry.qa.functions.Dashboard;
import com.cutanddry.qa.functions.Login;
import com.cutanddry.qa.utils.JsonUtil;
import org.testng.ITestResult;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.testng.asserts.SoftAssert;

public class VerifyTheSortingFunctionalityOfCatalogListViewTest extends TestBase {
static User user;
static String customerId = "16579";
static String sortItemCode = "Item Code";

@BeforeMethod
public void setUp() {
initialization();
user = JsonUtil.readUserLogin();
}

@Test(groups = "DOT-TC-1290")
public void VerifyTheSortingFunctionalityOfCatalogListView() throws InterruptedException {
SoftAssert softAssert = new SoftAssert();

Login.loginAsDistributor(user.getEmailOrMobile(), user.getPassword());
softAssert.assertTrue(Dashboard.isUserNavigatedToDashboard(), "Login failed - user not navigated to dashboard");

Dashboard.navigateToCustomers();
Customer.searchCustomerByCode(customerId);
softAssert.assertTrue(Customer.isCustomerSearchResultByCodeDisplayed(customerId), "Customer search failed - customer not found");

Customer.clickOnOrderGuide(customerId);
Customer.goToCatalog();
Customer.clickCatalogListView();

Customer.clickCatalogListViewSort(sortItemCode);
softAssert.assertTrue(Customer.areFirstThreeItemCodesSortedAscending(), "Items are not sorted in ascending order after first click on Item Code header");

Customer.clickCatalogListViewSort(sortItemCode);
softAssert.assertTrue(Customer.areFirstThreeItemCodesSortedDescending(), "Items are not sorted in descending order after second click on Item Code header");

softAssert.assertAll();
}

@AfterMethod
public void tearDown(ITestResult result) {
takeScreenshotOnFailure(result);
closeAllBrowsers();
}
}