@Override public void createPurchaseOrderForSerializedProductFromProductInventory( String serializedProduct, String poNumber, int quantity) { search.searchForProduct( ProductSearch.builder() .productName(serializedProduct) .inActive(true) .active(true) .create()); session.click(FIRST_EDIT_PRODUCT_BTN); waits.waitUntilVisible(ProductLocators.TITLE_EDITING_PRODUCT_TYPE); session.click(PRODUCT_INVENTORY_TAB); waits.waitUntilVisible(TITLE_PRODUCT_INVENTORY); session.selectDropDownText( SELECT_VENDOR_TO_CREATE_PO_AT_PRODUCT_INVENTORY_LST, VendorData.EXISTING_VENDOR_NAME.value()); session.click(CREATE_PO_BTN); waits.waitForPageLoad(); waits.waitUntilVisible(TITLE_CREATING_NEW_PO_LABEL); session.setText(PURCHASE_ORDER_NUMBER, poNumber); session.clear(QTY_FLD); session.setText(QTY_FLD, String.valueOf(quantity)); session.click(SAVE_BTN); waits.waitUntilVisible(TITLE_PURCHASE_ORDERS_LABEL); }
@Override public void showProductsForSelectedCategoryAndSubCategoryInDefaultPricing( DefaultPricing defaultPricing) { commonActions.navigateTo(NavMenuLink.DEFAULT_PRICING); commonActions.selectContentFrame(); waits.waitUntilVisible(TITLE); session.selectDropDownText(CATEGORY_LST, defaultPricing.getCategory().get()); waits.waitUntilVisible( By.xpath( "//select[@id='categorypickercatSelect']/option[contains(text(), '" + defaultPricing.getCategory().get() + "')]")); session.selectDropDownText(SUB_CATEGORY_LST, defaultPricing.getSubCategory().get()); waits.waitUntilVisible( By.xpath( "//select[@id='categorypickersubCatSelect']/option[contains(text(), '" + defaultPricing.getSubCategory().get() + "')]")); session.click(SHOW_PRODUCTS); waits.waitUntilVisible( By.xpath( "//td[text()='" + defaultPricing.getCategory().get() + "']/../td[text()='" + defaultPricing.getSubCategory().get() + "']/../td[text()='" + defaultPricing.getProductName().get() + "']")); }
@Override public void verifyDefectiveCountIsDisplayedZeroForNonSerializedProduct(String productName) { search.searchForProduct(ProductSearch.builder().productName(productName).create()); session.click(FIRST_EDIT_PRODUCT_BTN); waits.waitUntilVisible(ProductLocators.TITLE_EDITING_PRODUCT_TYPE); session.click(PRODUCT_INVENTORY_TAB); waits.waitUntilVisible(DEFECTIVE_NONSERIALIZED_ZERO); }
void verifyNoReceiveShipmentAndCreatePOButtons(String productName) { search.searchForProduct(ProductSearch.builder().productName(productName).create()); session.click(FIRST_EDIT_PRODUCT_BTN); waits.waitUntilVisible(ProductLocators.TITLE_EDITING_PRODUCT_TYPE); session.click(PRODUCT_INVENTORY_TAB); waits.waitUntilNotVisible(RECEIVE_SHIPMENT_BTN); waits.waitUntilNotVisible(CREATE_PO_BTN); }
@Override public void verifyAllFieldsAtProductInventoryPage( Product serialProduct, Product nonSerialProduct, String[] esnNumbers, Map<String[], String[]> productQuantityCountAndStatuses) { search.searchForProduct( ProductSearch.builder() .productName(serialProduct.getName().get()) .active(true) .inActive(true) .create()); session.click(FIRST_EDIT_PRODUCT_BTN); waits.waitUntilVisible(ProductLocators.TITLE_EDITING_PRODUCT_TYPE); verifyCommonFieldsAtProductInventory(); waits.waitUntilVisible(productAtAllStores(serialProduct)); Map<String[], String[]> productStatuses = productQuantityCountAndStatuses; for (Map.Entry<String[], String[]> entrySet : productStatuses.entrySet()) { String[] status = entrySet.getKey(); String[] quantityCounts = entrySet.getValue(); for (int i = 0; i < status.length; i++) { if (i == 0) { int j = Integer.parseInt(quantityCounts[i]) + 1; waits.waitUntilVisible(verifyQuantity(status[i], String.valueOf(j))); } else { waits.waitUntilVisible(verifyQuantity(status[i], quantityCounts[i])); } } } waits.waitUntilVisible( verifyQuantity(ProductStaticData.QUANTITY, String.valueOf(esnNumbers.length))); String newEsnLength = String.valueOf(esnNumbers.length - 1); waits.waitUntilVisible(verifyQuantity(ProductStaticData.AVAILABLE, newEsnLength)); waits.waitUntilVisible(verifyQuantity(ProductStaticData.TRANSFER, "1")); // Verify for the non Serialized product. search.searchForProduct( ProductSearch.builder() .productName(nonSerialProduct.getName().get()) .active(true) .inActive(true) .create()); session.click(FIRST_EDIT_PRODUCT_BTN); waits.waitUntilVisible(ProductLocators.TITLE_EDITING_PRODUCT_TYPE); verifyCommonFieldsAtProductInventory(); waits.waitUntilVisible(productAtAllStores(nonSerialProduct)); Map<String[], String[]> productCountAndStatuses = productQuantityCountAndStatuses; for (Map.Entry<String[], String[]> entry : productCountAndStatuses.entrySet()) { String[] statuses = entry.getKey(); String[] quantityCount = entry.getValue(); for (int i = 0; i < statuses.length; i++) { waits.waitUntilVisible(verifyQuantity(statuses[i], quantityCount[i])); } } }
@Override public void verifyOnlyEnabledVendorsInSelectedVendorDropdown( String productName, String disabledVendor, String enabledVendor) { search.searchForProduct( ProductSearch.builder().productName(productName).active(true).inActive(true).create()); session.click(FIRST_EDIT_PRODUCT_BTN); waits.waitUntilVisible(ProductLocators.TITLE_EDITING_PRODUCT_TYPE); session.click(PRODUCT_INVENTORY_TAB); waits.waitUntilVisible(TITLE_PRODUCT_INVENTORY); waits.waitUntilVisible(verifyEnabledVendorPresent(enabledVendor)); waits.waitUntilNotVisible(verifyDisabledVendorNotPresent(disabledVendor)); }
@Override public void updateCashDrawer(String nameOfCashDrawerToUpdate, CashDrawer drawer) { commonActions.navigateTo(NavMenuLink.CASH_DRAWER); commonActions.selectContentFrame(); session.click(CashDrawerLocators.getEditButton(nameOfCashDrawerToUpdate)); setFields(drawer); session.click(SAVE_BTN); waits.waitForPageLoad(); session.click(BACK_BTN); waits.waitUntilVisible(CashDrawerLocators.verifyRow(drawer)); }
@Override public void searchActiveProductUsingStatus(String productName) { commonActions.navigateTo(NavMenuLink.PRODUCT_TYPES); commonActions.selectContentFrame(); session.setChecked(ACTIVE_CHK_BOX, true); session.setChecked(INACTIVE_CHK_BOX, false); session.setText(SEARCH_FLD, productName); session.click(SUBMIT_BTN); waits.waitUntilVisible(verifySearchedProductAtProductsPage(productName)); session.setChecked(ACTIVE_CHK_BOX, false); session.setChecked(INACTIVE_CHK_BOX, true); session.click(SUBMIT_BTN); waits.waitUntilNotVisible(verifySearchedProductAtProductsPage(productName)); }
@Override public void addCashDrawer(CashDrawer drawer) { commonActions.navigateTo(NavMenuLink.CASH_DRAWER); commonActions.selectContentFrame(); session.click(NEW_CASH_DRAWER_LNK); setFields(drawer); session.click(SAVE_BTN); waits.waitForPageLoad(); session.click(BACK_BTN); waits.waitUntilVisible(CashDrawerLocators.verifyRow(drawer)); }
@Override public void viewEsnOfInactiveSerialProduct(Product serialProduct, String esnNumber) { search.searchForProduct( ProductSearch.builder() .productName(serialProduct.getName().get()) .active(true) .inActive(true) .create()); session.click(FIRST_EDIT_PRODUCT_BTN); waits.waitUntilVisible(ProductLocators.TITLE_EDITING_PRODUCT_TYPE); session.click(PRODUCT_INVENTORY_TAB); waits.waitUntilVisible(getEditButton(esnNumber)); session.click(getEditButton(esnNumber)); waits.waitUntilVisible(verifyEsnAtLocateProduct(esnNumber)); }
@Override public void verifyWarningMessageIsDisplayedWithUnprivilegedOfLocateProduct( Product product, String[] esnNumbers) { search.searchForProduct( ProductSearch.builder() .productName(product.getName().get()) .active(true) .inActive(true) .create()); session.click(FIRST_EDIT_PRODUCT_BTN); waits.waitUntilVisible(ProductLocators.TITLE_EDITING_PRODUCT_TYPE); session.click(PRODUCT_INVENTORY_TAB); waits.waitUntilVisible(TITLE_PRODUCT_INVENTORY); waits.waitUntilNotVisible(getEditButton(esnNumbers[0])); }
@Test(groups = "P2", singleThreaded = true) void validateNoChangeOrderIdProvided() { setupTest(); commonActions.navigateTo(NavMenuLink.CHANGE_ORDER_RECEIPT); commonActions.selectContentFrame(); session.click(ChangeOrderReceiptLocators.GET_DEPOSIT_BTN); waits.waitUntilVisible(ChangeOrderReceiptLocators.ERROR_NO_CHANGE_ORDER_ID_PROVIDED); }
@Override public void logout() { navigateTo(NavMenuLink.LOGOUT); // Added hack, overlay still causes issues when logging out // and test tries to log back in annoyingWaitHack(); waits.waitForPageLoad(); }
private void setupTest() { if (!storeSearchAction.storeExistsByName("DEPOSIT_STORE_16")) { store1 = MerchantStore.builder() .storeNumber("SN_DEP_16") .name("DEPOSIT_STORE_16".intern()) .status(StoreStatus.ACTIVE) .storeType(StoreType.STORE) .timeZoneText("IDT - Asia/Calcutta") .regionText("Mountain") .priceGroupText("Default Price Group") .salesTaxText("Salt Lake City (6.500000)") .salesTaxFloorPercentage(2.5) .pifTaxPercentage(1) .languageText("English") .operatingFund(100) .operatingFundMax(200) .safeLimit(100.00) .safeUpperLimit(200.00) .create(); storeActions.createMerchantStore(store1); employee = Employee.builder() .firstName("John") .lastName("Deposit") .userName("User16") .password("demo1234") .expirePasswordNow(false) .role(DefaultRoles.ADMINISTRATOR.getText()) .assignedStores(ImmutableList.of(store1.getName().get())) .active(true) .commissionsEnabled(true) .create(); employeeActions.addEmployeeAndLoginChangingExpiredPassword( employee, store1.getName().get(), "demo4321"); drawer1 = CashDrawer.builder() .name("Drawer_Dep_016") .merchantStoreName(store1.getName().get()) .openerString("7") .status(CashDrawer.Status.ENABLED) .operatingFund(30.0) .operatingFundUpperLimit(100.00) .create(); drawerActions.addCashDrawer(drawer1); reconcileActions.openCashDrawer(drawer1, drawer1.getOperatingFund().get(), true); waits.waitForPageLoad(); } else { commonActions.logout(); commonActions.initializeSession( employee.getUserName().get(), "demo4321", store1.getName().get()); } }
@Test(groups = "P2", singleThreaded = true) void validateInvalidChangeOrderId() { setupTest(); commonActions.navigateTo(NavMenuLink.CHANGE_ORDER_RECEIPT); commonActions.selectContentFrame(); session.setText(ChangeOrderReceiptLocators.CHANGE_ORDER_TXT_BOX, "invalid"); session.click(ChangeOrderReceiptLocators.GET_DEPOSIT_BTN); waits.waitUntilVisible(ChangeOrderReceiptLocators.ERROR_NO_DEPOSIT_FOR_ID); }
@Override public void verifyPurchaseOrderFromProductInventoryWithoutSelectingVendor( String nonSerializedProduct) { search.searchForProduct( ProductSearch.builder() .productName(nonSerializedProduct) .inActive(true) .active(true) .create()); session.click(FIRST_EDIT_PRODUCT_BTN); waits.waitUntilVisible(ProductLocators.TITLE_EDITING_PRODUCT_TYPE); session.click(PRODUCT_INVENTORY_TAB); waits.waitUntilVisible(TITLE_PRODUCT_INVENTORY); session.click(CREATE_PO_BTN); waits.waitUntilVisible(VENDOR_REQUIRED); }
@Override public void searchProductByNameUpcBarcodeProductType( ProductSearch search, List<String> products) { commonActions.navigateTo(NavMenuLink.PRODUCT_TYPES); commonActions.selectContentFrame(); waits.waitUntilVisible(TITLE); session.setChecked(ACTIVE_CHK_BOX, search.isActive().get()); // Search All Product Type products by product name session.setText(SEARCH_FLD, products.get(0)); session.click(SUBMIT_BTN); waits.waitUntilVisible(verifySearchedProductAtProductsPage(products.get(0))); session.setText(SEARCH_FLD, products.get(1)); session.click(SUBMIT_BTN); waits.waitUntilVisible(verifySearchedProductAtProductsPage(products.get(1))); session.setText(SEARCH_FLD, products.get(2)); session.click(SUBMIT_BTN); waits.waitUntilVisible(verifySearchedProductAtProductsPage(products.get(2))); session.setText(SEARCH_FLD, products.get(3)); session.click(SUBMIT_BTN); waits.waitUntilVisible(verifySearchedProductAtProductsPage(products.get(3))); session.setText(SEARCH_FLD, products.get(4)); session.click(SUBMIT_BTN); waits.waitUntilVisible(verifySearchedProductAtProductsPage(products.get(4))); session.setText(SEARCH_FLD, ""); // Search Product by UPC Barcode session.setText(UPCS_FLD, Joiners.COMMA.join(search.getUpcs().get())); session.click(SUBMIT_BTN); waits.waitUntilVisible(verifySearchedProductAtProductsPage(products.get(1))); session.setText(UPCS_FLD, ""); Map<String, String> map = new HashMap<String, String>(); map.put(ProductType.SERIALIZABLE.getText(), products.get(1)); map.put(ProductType.NON_SERIALIZABLE.getText(), products.get(0)); map.put(ProductType.RATE_PLAN.getText(), products.get(2)); map.put(ProductType.RATE_PLAN_UPGRADE.getText(), products.get(3)); map.put(ProductType.SERVICE_PRODUCT.getText(), products.get(4)); map.put(ProductType.RESTOCK.getText(), products.get(5)); // Search By Product Type for (ProductType type : search.getProductTypes().get()) { session.setText(SEARCH_FLD, map.get(type.getText())); session.selectDropDownText(AVAILABLE_PRODUCT_TYPES, type.getText()); session.click(PRODUCT_TYPE_SELECT_BTN); session.click(SUBMIT_BTN); waits.waitUntilVisible(verifySearchedProductAtProductsPage(map.get(type.getText()))); session.clear(SEARCH_FLD); } }
private void login(final String userName, final String password, final String storeName) { checkNotNull(userName); checkNotNull(password); checkNotNull(storeName); // assumes you are on the login page. selectMainWindow(); waitForTime(2); selectContentFrame(); waitForTime(2); waits.waitUntilVisible(By.xpath("//span[contains(text(),'Login')]")); annoyingWaitHack(); session.setText(By.id("userName"), userName); waits.waitUntilVisible(By.xpath("//div//span[contains(text(),'Login')]")); annoyingWaitHack(); session.setText(By.id("password"), password); annoyingWaitHack(); if (session.existsNow(By.id("autoCompleteField"))) { session.setText(By.id("autoCompleteField"), storeName); } else { session.selectDropDownText(By.id("store"), storeName); } session.findNow(DEFAULT_SUBMIT_0).click(); try { Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); } }
@Override public void adjustDefaultPricing(String updatedDefaultPrice) { commonActions.navigateTo(NavMenuLink.DEFAULT_PRICING); commonActions.selectContentFrame(); waits.waitUntilVisible(TITLE); session.selectDropDownText(CATEGORY_LST, CategoryData.ACCESSORIES.value()); session.selectDropDownText(SUB_CATEGORY_LST, CategoryData.ACCESSORIES_BATTERIES.value()); session.click(SHOW_PRODUCTS); session.setText( DefaultPricingLocators.getDefaultPriceForProduct( ProductData.EXISTING_NON_SERIAL_PROD_NAME.value()), updatedDefaultPrice); session.click( DefaultPricingLocators.getProductSelectCheckBox( ProductData.EXISTING_NON_SERIAL_PROD_NAME.value())); session.click(ADJUST_PRICES); waits.waitUntilVisible( By.xpath( "//td[text()='" + ProductData.EXISTING_NON_SERIAL_PROD_NAME.value() + "']/../td//input[@value='" + updatedDefaultPrice + "']")); }
@Test(groups = "P2", singleThreaded = true) void validateChangeOrderIdAlreadyExists() { setupTest(); changeOrderActions.createCompleteChangeOrder("3B1", "10", "4B2"); // (3140)Verify that adding trailing and leading spaces in Change Order ID to get deposit // displays results. receiptActions.doReceipt(" 3B1 ", "2"); Assert.assertTrue(session.existsNow(ChangeOrderReceiptLocators.COUNTER_NAME)); commonActions.navigateTo(NavMenuLink.CHANGE_ORDER_RECEIPT); commonActions.selectContentFrame(); Assert.assertTrue(session.existsNow(ChangeOrderReceiptLocators.CHANGE_ORDER_ID_LBL)); session.setText(ChangeOrderReceiptLocators.CHANGE_ORDER_TXT_BOX, "3B1"); session.click(ChangeOrderReceiptLocators.GET_DEPOSIT_BTN); waits.waitUntilVisible(ChangeOrderReceiptLocators.ERROR_CHANGE_ORDER_ALREADY_EXISTS); }
void verifyCommonFieldsAtProductInventory() { session.click(PRODUCT_INVENTORY_TAB); waits.waitUntilVisible(TITLE_PRODUCT_INVENTORY); waits.waitUntilVisible(MERCHANT_STORE_DROPDOWN); waits.waitUntilVisible(DISPLAY_REPORT_BTN); waits.waitUntilVisible(DISPLAY_TREND_BTN); waits.waitUntilVisible(CommonLocators.DEFAULT_PAGE_LINK); waits.waitUntilVisible(SELECT_VENDOR_TO_CREATE_PO_AT_PRODUCT_INVENTORY_LST); waits.waitUntilVisible(CREATE_PO_BTN); }
@Override public void searchMultipleProductsUsingMultipleUPCs(String[] upcs, String[] products) { commonActions.navigateTo(NavMenuLink.PRODUCT_TYPES); commonActions.selectContentFrame(); session.setChecked(ACTIVE_CHK_BOX, true); session.setChecked(INACTIVE_CHK_BOX, true); session.clear(SEARCH_FLD); for (String upc : upcs) { session.appendText(UPCS_FLD, upc + ","); } session.click(SUBMIT_BTN); for (String productName : products) { waits.waitUntilVisible(verifySearchedProductAtProductsPage(productName)); } session.clear(UPCS_FLD); session.click(SUBMIT_BTN); }
@Override public void searchForProduct(ProductSearch search) { commonActions.navigateTo(NavMenuLink.PRODUCT_TYPES); commonActions.selectContentFrame(); // the default is checked if (search.isActive().isPresent()) { session.setChecked(ACTIVE_CHK_BOX, search.isActive().get()); } // the default is un-checked if (search.isInActive().isPresent()) { if (search.isInActive().get() == true) { if (!session.existsNow(CHECKED_INACTIVE_CHK_BOX)) { session.click(INACTIVE_CHK_BOX); } } if (search.isInActive().get() == false) { if (session.existsNow(CHECKED_INACTIVE_CHK_BOX)) { session.click(INACTIVE_CHK_BOX); } } } session.setText(SEARCH_FLD, search.getProductName()); if (search.getUpcs().isPresent()) { session.clear(SEARCH_FLD); session.setText(UPCS_FLD, Joiners.COMMA.join(search.getUpcs().get())); } if (search.getRowsPerPage().isPresent()) { session.selectDropDownText( ROWS_PER_PAGE, String.valueOf(search.getRowsPerPage().get().getRowsPerPage())); } if (search.getProductTypes().isPresent()) { for (ProductType type : search.getProductTypes().get()) { session.selectDropDownText(AVAILABLE_PRODUCT_TYPES, type.getText()); session.click(PRODUCT_TYPE_SELECT_BTN); } } waits.waitForElementToClick(SUBMIT_BTN); session.click(SUBMIT_BTN); }
@Override public void verifyPageNavigateToLocateProduct(Product product, String esnNumbers[]) { search.searchForProduct( ProductSearch.builder() .productName(product.getName().get()) .active(true) .inActive(true) .create()); session.click(FIRST_EDIT_PRODUCT_BTN); waits.waitUntilVisible(ProductLocators.TITLE_EDITING_PRODUCT_TYPE); session.click(PRODUCT_INVENTORY_TAB); waits.waitUntilVisible(TITLE_PRODUCT_INVENTORY); session.click(getEditButton(esnNumbers[0])); waits.waitUntilVisible(verifyEsnAtLocateProduct(esnNumbers[0])); if (session.existsNow(getDefaultPrice(product.getDefaultPrice().get()))) { waits.waitUntilVisible(getDefaultPrice(product.getDefaultPrice().get())); } waits.waitUntilVisible(verifyCategory(product.getCategoryText().get())); waits.waitUntilVisible(verifyShortDescription(product.getShortDescription().get())); waits.waitUntilVisible(verifyStoreName(LoginData.STORE.value())); }
@Override public void initializeSession(String userName, String password, String storeName) { login(userName, password, storeName); waits.waitForPageLoad(); }
@Override public void selectMainWindow() { annoyingWaitHack(); waits.waitForMainWindowAndSwitch(); }
@Override public void selectContentFrame() { waits.waitForFrameAndSwitch("content"); }
@Override public void acceptAlert() { Alert alert = waits.waitForAlertAndSwitch(); alert.accept(); }