internal void VerifyErrorMessageCheckout(Table dataToAdd) { ShoppingBag bag = dataToAdd.CreateInstance <ShoppingBag>(); logOut.ClickButton(); Wait.Seconds(2); checkoutEmail.ClearData(); checkoutFirstName.BlankValue(); checkoutLastName.BlankValue(); checkoutCountry.DropDownSelectionByText(bag.Country); ElementLocatorExtensions.GetElementXpath(checkoutsBtn, "Continue to shipping").ClickButton(); Assert.Multiple(() => { Assert.AreEqual(checkoutEmailError.GetElementValue(), ErrorMessages.CheckoutEmailError, "Checkout email error is not as expected."); Assert.AreEqual(checkoutFirstNameError.GetElementValue(), ErrorMessages.CheckoutFirstNameError, "Checkout first name error is not as expected."); Assert.AreEqual(checkoutLastNameError.GetElementValue(), ErrorMessages.CheckoutLastNameError, "Checkout last name error is not as expected."); Assert.AreEqual(checkoutAddressError.GetElementValue(), ErrorMessages.CheckoutAddressError, "Checkout address error is not as expected."); Assert.AreEqual(checkoutCityError.GetElementValue(), ErrorMessages.CheckoutCityError, "Checkout email city is not as expected."); Assert.AreEqual(checkoutStateError.GetElementValue(), ErrorMessages.CheckoutStateError, "Checkout email state is not as expected."); Assert.AreEqual(checkoutZipCodeError.GetElementValue(), ErrorMessages.CheckoutZipCodeError, "Checkout zip code error is not as expected."); }); if (orderSummaryToggle.IsDisplayed()) { orderSummaryToggle.Click(); Wait.Seconds(1); } checkoutGiftCardInput.InputKey(bag.GiftCardCode); discountBtn.ClickButton(); Assert.AreEqual(giftCardCodeError.GetElementValue(), ErrorMessages.GiftCardCodeError, "Checkout gift card code error is not as expected."); }
internal void PreviewImages() { for (int i = 0; i <= 3; i++) { previewLoader.UntilElementIsNotDisplayed(new TimeSpan(0, 0, 80)); ElementLocatorExtensions.GetElementXpath(commonButton, "Design").ClickButton(); selectArtwork.SelectElementFromLooping("Artwork1").ClickButton(); ElementLocatorExtensions.GetElementXpath(commonButton, "Preview").ClickButton(); previewLoader.UntilElementIsNotDisplayed(new TimeSpan(0, 0, 80)); if (previewItems.IsDisplayed()) { foreach (IWebElement card in previewItems.GetElements()) { card.ClickButton(); Wait.Seconds(1); } break; } continue; } if (!previewItems.IsDisplayed()) { Assert.Fail("Preview items are not displayed."); } }
internal void RemoveProductFromHomePage(string artwork, string subcategory) { var getProductCard = ElementLocatorExtensions.GetElementXpath(productCard, artwork, subcategory); if (!getProductCard.GetElements().Count.Equals(0)) { if (getProductCard.GetElements().Count > 1) { int index = 0; foreach (IWebElement card in getProductCard.GetElements()) { card.FindElements(moreOptionLogo)[index].HoverOverElement(); card.FindElements(moreOptionLogo)[index].ClickButton(); Wait.Seconds(1); card.FindElements(cardRemoveOption)[index].ClickButton(); Wait.Seconds(6); } } else { moreOptionLogo.HoverOverElement(); moreOptionLogo.Click(); Wait.Seconds(1); moreActions.SelectElementFromLooping("Remove").ClickButton(); Wait.Seconds(2); successMessage.UntilElementIsDisplayed(new TimeSpan(0, 0, 5)); Assert.AreEqual(successMessage.GetElementValue(), ToastMessage.productRemoved, "Product is not removed successfully."); } } }
internal void ClickContinueShipping(string btnName) { ElementLocatorExtensions.Scrolldown(); ElementLocatorExtensions.GetElementXpath(checkoutsBtn, btnName).HoverOverElement(); ElementLocatorExtensions.GetElementXpath(checkoutsBtn, btnName).ClickButton(); Wait.Seconds(2); }
internal void IsDataUpdatedForShippingStep(string action) { var valueToBeCompared = ElementLocatorExtensions.GetElementXpath(changeContent, action).GetElementValue(); if (action.Equals("Change contact information")) { Assert.Multiple(() => { Assert.AreNotEqual(valueToBeCompared, DictionaryProperties.Details["contactBefore"]); Assert.AreEqual(valueToBeCompared, DictionaryProperties.Details["Email"], "Contact info is not updated."); }); } else if (action.Equals("Change shipping address")) { Assert.Multiple(() => { Assert.IsTrue(valueToBeCompared.Contains(DictionaryProperties.Details["Address"]), "Checkout address is not as expected."); Assert.IsTrue(valueToBeCompared.Contains(DictionaryProperties.Details["City"]), "Checkout city name is not as expected."); Assert.IsTrue(valueToBeCompared.Contains(DictionaryProperties.Details["PinCode"]), "Checkout pin code is not as expected."); }); } else if (action.Equals("Change shipping method")) { Assert.IsFalse(valueToBeCompared.Contains(DictionaryProperties.Details["shippinhgMethodBefore"])); Assert.IsTrue(valueToBeCompared.Contains(DictionaryProperties.Details["ShippingMethod"])); } }
internal void SelectProductTypeTitle(string productType) { var subcatagoryCount1 = ElementLocatorExtensions.GetElementXpath(productSubType, productType).GetElements(); foreach (var item in subcatagoryCount1) { var text = ((RemoteWebElement)item).Text; name1.Add(text); } ElementLocatorExtensions.GetElementXpath(productTypeTitle, productType).ClickButton(); Wait.Seconds(1); IList <string> name2 = new List <string>(); var subcatagoryCount2 = subcatageryType.GetElements(); foreach (var item in subcatagoryCount2) { if (!string.IsNullOrEmpty(item.Text)) { var text2 = ((RemoteWebElement)item).Text.Replace("\r\n", "").Remove(item.Text.Replace("\r\n", "").Length - 1); name2.Add(text2); } } for (int i = 0; i <= 3; i++) { Assert.IsTrue(name2[i].Contains(name1[i]), "Product category elements are not as expected."); } }
internal void VerifyDialogueBoxpageHeader(string headingName) { if (ElementLocatorExtensions.GetElementXpath(commonHeaderDialogueBox, headingName).IsDisplayed()) { Assert.AreEqual(ElementLocatorExtensions.GetElementXpath(commonHeaderDialogueBox, headingName).GetElementValue(), headingName, "Popup header name is not as expected."); } }
internal void IsButtonDisabled(string buttonName) { if (ElementLocatorExtensions.GetElementXpath(commonButton, buttonName).IsDisplayed()) { Assert.IsFalse(ElementLocatorExtensions.GetElementXpath(commonButton, buttonName).IsEnabled(), "Button is not disabled."); } }
internal void IsProductAdded() { if (giftBoxQuantity.IsDisplayed()) { ClickGiftBoxMinusBtn(); } if (cartName.IsDisplayed()) { closeBtn.Click(); ElementLocatorExtensions.GetElementXpath(selectMenu, "Create New Product").ClickButton(); Wait.Seconds(3); ElementLocatorExtensions.GetElementXpath(getCategoryAndSubCategory, "bags", "Handbags").ClickButton(); productSubCatText.UntilElementIsDisplayed(new TimeSpan(0, 0, 60)); ElementLocatorExtensions.GetElementXpath(selectSubCatagotyTitle, "Tote Bag").ClickButton(); ElementLocatorExtensions.GetElementXpath(commonButton, "Upload Artwork").UntilElementIsDisplayed(new TimeSpan(0, 0, 15)); if (DictionaryProperties.Details["ScenarioName"].Contains("mobile view")) { ElementLocatorExtensions.GetElementXpath(commonButton, "Choose From Gallery").ClickButton(); Wait.Seconds(2); } selectArtwork.SelectElementFromLooping("Artwork(1)").ClickButton(); ElementLocatorExtensions.GetElementXpath(commonButton, "Launch Product").UntilElementIsEnabled(new TimeSpan(0, 0, 15)); ElementLocatorExtensions.GetElementXpath(commonButton, "Launch Product").ClickButton(); successText.UntilElementIsDisplayed(new TimeSpan(0, 0, 20)); ElementLocatorExtensions.GetElementXpath(commonButton, "Skip").ClickButton(); plusButton.UntilElementIsDisplayed(new TimeSpan(0, 0, 60)); Wait.Seconds(3); } }
internal void SelectSubCategoryType(string subCategoryType) { DictionaryProperties.Details["SubCategoryType"] = subCategoryType; ElementLocatorExtensions.GetElementXpath(selectSubCatagotyTitle, subCategoryType).ClickButton(); CommonPage commonPage = new CommonPage(Driver, _appSettings); commonPage.LoadingBar(); }
internal void ClickAndUploadPhotos(string action) { CommonPage commonPage = new CommonPage(Driver, _appSettings); commonPage.GenerateImage(); ElementLocatorExtensions.GetElementXpath(commonButton, action).Click(); Wait.Seconds(2); commonPage.UploadPhoto(); }
internal void CommonButtonClickAction(string buttonName) { if (ElementLocatorExtensions.GetElementXpath(commonButton, buttonName).IsDisplayed()) { ElementLocatorExtensions.GetElementXpath(commonButton, buttonName).ClickButton(); CommonPage commonPage = new CommonPage(Driver, _appSettings); commonPage.LoadingBar(); } }
internal void VerifyTranspaentBadgeCount(string productName) { CommonPage commonPage = new CommonPage(Driver, _appSettings); commonPage.LaunchPageLoader(); if (ElementLocatorExtensions.GetElementXpath(badgeCount, productName).IsDisplayed()) { Assert.AreEqual(ElementLocatorExtensions.GetElementXpath(badgeCount, productName).GetElementValue(), productCheckbox.GetElements().Count.ToString(), "Batch count is not as expected."); } }
internal void ClickSubCatImage(string subCatImage) { DictionaryProperties.Details["SubCategoryType"] = subCatImage; if (!ElementLocatorExtensions.GetElementXpath(subCatImg, subCatImage).IsDisplayed()) { rightArrow.Click(); } ElementLocatorExtensions.GetElementXpath(subCatImg, subCatImage).Click(); Wait.Seconds(3); }
internal void PromoteProduct(string artwork, string subcategory) { var productCard = ElementLocatorExtensions.GetElementXpath(productCardDetails, artwork, subcategory); int index = 0; foreach (IWebElement card in productCard.GetElements()) { card.FindElements(promoteProduct)[index].ClickButton(); } }
internal void RemoveTheProduct(string product) { var removeBtnList = ElementLocatorExtensions.GetElementXpath(productRemove, DictionaryProperties.Details["Artwork"], product); foreach (IWebElement removeBtn in removeBtnList.GetElements()) { removeBtn.HoverOverElement(); removeBtn.ClickButton(); Wait.Milliseconds(500); } }
internal void IsProductCardNotDisplayed(string artwork, string subcategory) { Wait.Seconds(5); Assert.IsFalse(ElementLocatorExtensions.GetElementXpath(productCard, artwork, subcategory).IsDisplayed(), "Product card is displayed."); if (DictionaryProperties.Details["ScenarioName"].Equals(_appSettings.ScenarioName.AddProductInBag)) { Browser.RefreshPage(); Wait.Seconds(1); } Browser.RefreshPage(); }
internal void VerifyDashboradStatus(string status, string product) { CommonPage commonPage = new CommonPage(Driver, _appSettings); commonPage.LoadingBar(); var productList = ElementLocatorExtensions.GetElementXpath(productStatus, DictionaryProperties.Details["Artwork"], product); foreach (IWebElement ele in productList.GetElements()) { ele.HoverOverElement(); Assert.IsTrue(ele.Text.Equals(status), "Status is not as expected."); } }
internal void VerifypageHeader(string headingName) { Wait.Seconds(3); ElementLocatorExtensions.GetElementXpath(getCommonHeader, headingName).UntilElementIsDisplayed(new TimeSpan(0, 0, 120)); Assert.AreEqual(ElementLocatorExtensions.GetElementXpath(getCommonHeader, headingName).GetElementValue(), headingName, "Popup header name is not as expected."); if (giftBoxQuantity.IsDisplayed()) { DictionaryProperties.Details["GiftBoxCountBefore"] = giftBoxQuantity.GetElementValue(); } else { DictionaryProperties.Details["GiftBoxCountBefore"] = "0"; } }
internal void SetPaymentDataWithValidations(StorefrontData storefront) { //paymentMethod.ClickButton(); //paymentMethodList.ClickButton(); Browser.SwitchToFrame(iFrame.GetElement()); cardNumber.InputKey(storefront.InvalidCardNumber); Browser.SwitchToDefaultContent(); Assert.AreEqual(ErrorMessages.InvalidCardNum, paymentsError.GetElementValue()); Driver.SwitchTo().Frame(iFrame.GetElement()); cardNumber.InputKey(storefront.ValidCardNumber); Driver.SwitchTo().DefaultContent(); if (DictionaryProperties.Details["ScenarioName"].Contains(_appSettings.ScenarioName.PromoteDesign)) { ElementLocatorExtensions.GetElementXpath(commonButton, "Next").ClickButton(); } else { ElementLocatorExtensions.GetElementXpath(commonButton, "Add Card").ClickButton(); } Assert.AreEqual(ErrorMessages.RequiredExpError, paymentsError.GetElementValue()); Driver.SwitchTo().Frame(iFrame.GetElement()); expires.InputKey(storefront.InvalidExpires); Driver.SwitchTo().DefaultContent(); Assert.AreEqual(ErrorMessages.InvaidExp, paymentsError.GetElementValue()); Driver.SwitchTo().Frame(iFrame.GetElement()); expires.InputKey(storefront.ValidExpires); CVC.InputKey(storefront.InvalidCVC); Driver.SwitchTo().DefaultContent(); if (DictionaryProperties.Details["ScenarioName"].Contains(_appSettings.ScenarioName.PromoteDesign)) { ElementLocatorExtensions.GetElementXpath(commonButton, "Next").ClickButton(); } else { ElementLocatorExtensions.GetElementXpath(commonButton, "Add Card").ClickButton(); } Assert.AreEqual(ErrorMessages.RequiredCVC, paymentsError.GetElementValue()); Driver.SwitchTo().Frame(iFrame.GetElement()); CVC.InputKey(storefront.ValidCVC); Driver.SwitchTo().DefaultContent(); if (DictionaryProperties.Details["ScenarioName"].Contains(_appSettings.ScenarioName.PromoteDesign)) { ElementLocatorExtensions.GetElementXpath(commonButton, "Next").ClickButton(); } else { ElementLocatorExtensions.GetElementXpath(commonButton, "Add Card").ClickButton(); } Assert.AreEqual(ErrorMessages.RequiredPostal, paymentsError.GetElementValue()); }
internal void RelaunchProduct(string artwork, string product) { DictionaryProperties.Details["Artwork"] = artwork; var relaunchBtnList = ElementLocatorExtensions.GetElementXpath(productRelaunch, artwork, product); foreach (IWebElement relaunchBtn in relaunchBtnList.GetElements()) { relaunchBtn.HoverOverElement(); relaunchBtn.ClickButton(); Wait.Milliseconds(1500); } if (relaunchBtnList.GetElements().Count.Equals(0)) { Assert.Fail("There is no product in the list with name."); } }
internal void IfArtworkUploadedThenDelete(string action) { SelectHomePageTab("gallery"); Wait.Seconds(3); foreach (IWebElement tab in designCardTitle.GetElements()) { if (tab.Text.Contains(action)) { designCardTitle.SelectElementFromLooping(action).ClickButton(); Wait.Seconds(3); ElementLocatorExtensions.GetElementXpath(commonButton, "Edit").Click(); deleteIcon.ClickButton(); break; } } }
internal void SelectChangeButton(string buttonName, string stepName) { if (stepName.Equals("shipping")) { DictionaryProperties.Details["contactBefore"] = ElementLocatorExtensions.GetElementXpath(changeContent, "Change contact information").GetElementValue(); DictionaryProperties.Details["shippingAddressBrefore"] = ElementLocatorExtensions.GetElementXpath(changeContent, "Change shipping address").GetElementValue(); } else if (stepName.Equals("payment")) { DictionaryProperties.Details["contactBefore"] = ElementLocatorExtensions.GetElementXpath(changeContent, "Change contact information").GetElementValue(); DictionaryProperties.Details["shippingAddressBrefore"] = ElementLocatorExtensions.GetElementXpath(changeContent, "Change shipping address").GetElementValue(); DictionaryProperties.Details["shippinhgMethodBefore"] = ElementLocatorExtensions.GetElementXpath(changeContent, "Change shipping method").GetElementValue(); } ElementLocatorExtensions.GetElementXpath(editPaymentStep, buttonName).ClickButton(); Wait.Seconds(2); currentActiveHeader.UntilElementIsDisplayed(new TimeSpan(0, 0, 15)); }
internal void AddAProductOnHomePage(string category, string productType, string subCategory) { addProductCard.ClickButton(); Wait.Seconds(3); ElementLocatorExtensions.GetElementXpath(getCategoryAndSubCategory, category, productType).ClickButton(); productSubCatText.UntilElementIsDisplayed(new TimeSpan(0, 0, 60)); ElementLocatorExtensions.GetElementXpath(selectSubCatagotyTitle, subCategory).ClickButton(); ElementLocatorExtensions.GetElementXpath(commonButton, "Upload Artwork").UntilElementIsDisplayed(new TimeSpan(0, 0, 15)); if (DictionaryProperties.Details["ScenarioName"].Contains("mobile view")) { ElementLocatorExtensions.GetElementXpath(commonButton, "Choose From Gallery").ClickButton(); Wait.Seconds(2); } selectArtwork.SelectElementFromLooping("Artwork1").ClickButton(); ElementLocatorExtensions.GetElementXpath(commonButton, "Launch Product").UntilElementIsEnabled(new TimeSpan(0, 0, 15)); ElementLocatorExtensions.GetElementXpath(commonButton, "Launch Product").ClickButton(); successText.UntilElementIsDisplayed(new TimeSpan(0, 0, 120)); Wait.Seconds(3); closeIcon.Click(); Wait.Seconds(1); }
internal void SelectMenu(string menu, string submenu) { if (menuToggle.IsDisplayed()) { menuToggle.ClickButton(); ElementLocatorExtensions.GetElementXpath(selectMenuMobile, menu).ClickButton(); } else { ElementLocatorExtensions.GetElementXpath(selectMenu, menu).ClickButton(); } Wait.Seconds(3); if (!string.IsNullOrEmpty(submenu)) { ElementLocatorExtensions.GetElementXpath(selectSubMenu, menu, submenu).ClickButton(); Wait.Seconds(1); } if (collectionTitle.IsDisplayed()) { DictionaryProperties.Details["CollectionTitle"] = collectionTitle.GetElementValueByAttribute("value").ToLower(); } }
internal void SelectDropdownOptions(string menu, string submenu) { if (submenu.Contains(" ")) { DictionaryProperties.Details["SelectedTag"] = submenu.ToUpper().Replace(" ", "_"); } else if (submenu.Contains("-")) { DictionaryProperties.Details["SelectedTag"] = submenu.ToUpper().Replace("-", "_"); } else { DictionaryProperties.Details["SelectedTag"] = submenu.ToUpper(); } if (ElementLocatorExtensions.GetElementXpath(subHeadCloseBtn, DictionaryProperties.Details["SelectedTag"]).IsDisplayed()) { ElementLocatorExtensions.GetElementXpath(subHeadCloseBtn, DictionaryProperties.Details["SelectedTag"]).ClickButton(); Wait.Seconds(1); } ElementLocatorExtensions.GetElementXpath(dropdownMenu, menu).ClickButton(); ElementLocatorExtensions.GetElementXpath(dropdownSubMenu, menu, submenu).ClickButton(); }
internal void IsADesignAdded() { if (noDesign.IsDisplayed()) { ElementLocatorExtensions.GetElementXpath(selectMenu, "Create New Product").ClickButton(); Wait.Seconds(2); ElementLocatorExtensions.GetElementXpath(getCategoryAndSubCategory, "bags", "Handbags").ClickButton(); productSubCatText.UntilElementIsDisplayed(new TimeSpan(0, 0, 15)); ElementLocatorExtensions.GetElementXpath(selectSubCatagotyTitle, "Tote Bag").ClickButton(); ElementLocatorExtensions.GetElementXpath(commonButton, "Launch Product").UntilElementIsDisplayed(new TimeSpan(0, 0, 15)); CommonPage commonPage = new CommonPage(Driver, _appSettings); commonPage.GenerateImage(); ElementLocatorExtensions.GetElementXpath(commonButton, "Upload Artwork").Click(); Wait.Seconds(2); commonPage.UploadPhoto(); inputDesignName.InputKey("Artwork1"); Wait.Seconds(1); ElementLocatorExtensions.GetElementXpath(commonButton, "Save").ClickButton(); Wait.Seconds(4); closeIcon.Click(); Wait.Seconds(3); } }
internal void SelectProductToCreate(string category, string subcategory) { ElementLocatorExtensions.GetElementXpath(getCategoryAndSubCategory, category, subcategory).ClickButton(); Wait.Seconds(2); }
internal void IsProductTitleDisplayed(string productTitle) { Assert.IsTrue(ElementLocatorExtensions.GetElementXpath(productTypeTitle, productTitle).IsDisplayed(), "Product title is not displayed."); }
internal void ClickAction(SubCategoryType subCategoryType) { ElementLocatorExtensions.GetElementXpath(productTypeTitle, "bags").ClickButton(); Wait.Seconds(1); this.GetActionButton(subCategoryType).Click(); }