public void EditInternationalAddress() { var testUser = TestDataFactory.CreateLoginAccount(); AddressModel testBillingAddress = new AddressModel { country = "MX", CompanyName = "SDET", state = "CO", city = "test city", street = "elm street", postal = "22770", apartment = "Suite s4" }; PaymentOptionModel testCardtoken = new PaymentOptionModel { LastFourDigits = "1111", Cvv = "077", ExpirationMont = "12", ExpirationYear = "26", HolderName = "pika", CardNumber = "4111111111111111" }; AddressModel expectedBillingAddress = new AddressModel { country = "MX", CompanyName = "SDET", state = "Estado de baja california", city = "Ensenada", street = "Calle 3", postal = "22790", apartment = "Suite 24" }; string currentPaymentData = $"{testCardtoken.LastFourDigits} {testCardtoken.ExpirationMont}/{testCardtoken.ExpirationYear}"; AddressModel actualBillingAddressValues = new AddressModel(); IndexPage indexPage = new IndexPage(driver, url); LoginPage loginPage = indexPage.Header.ClickOnSignIn(); indexPage = loginPage.Login(testUser.Email, testUser.Password); PaymentOptionsHomePage paymentsHomePage = indexPage.Header.ClickOnPaymentOptions(); //Add a new credit card PaymentOptionsCreatePage addPaymentPage = paymentsHomePage.ClickOnAddNewCreditCard(); addPaymentPage.FillCardTokenForm(testCardtoken); addPaymentPage.SelectBillingAddressOption(BillingAddressOptionsEnum.AddNew); addPaymentPage.SetInputAddressValue(AddressInputs.Country, testBillingAddress.country); addPaymentPage.SetInputAddressValue(AddressInputs.CompanyName, testBillingAddress.CompanyName); addPaymentPage.SetInputAddressValue(AddressInputs.Street, testBillingAddress.street); addPaymentPage.SetInputAddressValue(AddressInputs.Apartment, testBillingAddress.apartment); addPaymentPage.SetInputAddressValue(AddressInputs.City, testBillingAddress.city); addPaymentPage.SetInputAddressValue(AddressInputs.State, testBillingAddress.state); addPaymentPage.SetInputAddressValue(AddressInputs.Postal, testBillingAddress.postal); addPaymentPage.ClickOnSubmit(); addPaymentPage.IsAppBusy(); paymentsHomePage = addPaymentPage.CloseModal(ModalsEnum.Information); Thread.Sleep(1000); //Begin testing here paymentsHomePage.ClickOnPaymentOption(AccessLevel.User, currentPaymentData); PaymentOptionsEditPage editPaymentPage = paymentsHomePage.ContentModal.ClickOnEdit(); editPaymentPage.IsAppBusy(); editPaymentPage.ClickOnBillingAddressOption(BillingAddressOptions.NewOne); editPaymentPage.SetInputAddressValue(AddressInputs.Country, expectedBillingAddress.country); editPaymentPage.SetInputAddressValue(AddressInputs.CompanyName, expectedBillingAddress.CompanyName); editPaymentPage.SetInputAddressValue(AddressInputs.Street, expectedBillingAddress.street); editPaymentPage.SetInputAddressValue(AddressInputs.Apartment, expectedBillingAddress.apartment); editPaymentPage.SetInputAddressValue(AddressInputs.City, expectedBillingAddress.city); editPaymentPage.SetInputAddressValue(AddressInputs.State, expectedBillingAddress.state); editPaymentPage.SetInputAddressValue(AddressInputs.Postal, expectedBillingAddress.postal); editPaymentPage.ClickOnSubmit(); editPaymentPage.IsAppBusy(); paymentsHomePage = editPaymentPage.CloseModal(ModalsEnum.Information); Thread.Sleep(1000); //make sure the update has done paymentsHomePage.ClickOnPaymentOption(AccessLevel.User, currentPaymentData); editPaymentPage = paymentsHomePage.ContentModal.ClickOnEdit(); editPaymentPage.IsAppBusy(); actualBillingAddressValues.country = editPaymentPage.GetBillingAddressInputValue(AddressInputs.Country); actualBillingAddressValues.CompanyName = editPaymentPage.GetBillingAddressInputValue(AddressInputs.CompanyName); actualBillingAddressValues.street = editPaymentPage.GetBillingAddressInputValue(AddressInputs.Street); actualBillingAddressValues.apartment = editPaymentPage.GetBillingAddressInputValue(AddressInputs.Apartment); actualBillingAddressValues.city = editPaymentPage.GetBillingAddressInputValue(AddressInputs.City); actualBillingAddressValues.postal = editPaymentPage.GetBillingAddressInputValue(AddressInputs.Postal); actualBillingAddressValues.state = editPaymentPage.GetBillingAddressInputValue(AddressInputs.State); paymentsHomePage = editPaymentPage.ClickOnCancel(); Assert.IsTrue(expectedBillingAddress.CompanyName == actualBillingAddressValues.CompanyName, $"Expected: '{expectedBillingAddress.CompanyName}' Got: '{actualBillingAddressValues.CompanyName}'"); Assert.IsTrue(actualBillingAddressValues.country.Contains(expectedBillingAddress.country), $"Expected: '{expectedBillingAddress.country}' Got: '{actualBillingAddressValues.country}'"); Assert.IsTrue(expectedBillingAddress.street == actualBillingAddressValues.street, $"Expected: '{expectedBillingAddress.street}' Got: '{actualBillingAddressValues.street}'"); Assert.IsTrue(expectedBillingAddress.apartment == actualBillingAddressValues.apartment, $"Expected: '{expectedBillingAddress.apartment}' Got: '{actualBillingAddressValues.apartment}'"); Assert.IsTrue(expectedBillingAddress.city == actualBillingAddressValues.city, $"Expected: '{expectedBillingAddress.city}' Got: '{actualBillingAddressValues.city}'"); Assert.IsTrue(expectedBillingAddress.postal == actualBillingAddressValues.postal, $"Expected: '{expectedBillingAddress.postal}' Got: '{actualBillingAddressValues.postal}'"); Assert.IsTrue(expectedBillingAddress.state == actualBillingAddressValues.state, $"Expected: '{expectedBillingAddress.state}' Got: '{actualBillingAddressValues.state}'"); }
public void EditPaymentMakeDefault() { var testUser = TestDataFactory.CreateLoginAccount(); PaymentOptionModel testCardtoken = new PaymentOptionModel { LastFourDigits = "1111", Cvv = "077", ExpirationMont = "12", ExpirationYear = "26", HolderName = "pika", CardNumber = "4111111111111111" }; AddressModel testBillingAddress = new AddressModel { country = "MX", CompanyName = "SDET", state = "Estado de baja california", city = "Ensenada", street = "Calle 3", postal = "22790", apartment = "Suite 24" }; string selectPayment = $"{testCardtoken.LastFourDigits} {testCardtoken.ExpirationMont}/{testCardtoken.ExpirationYear}"; IndexPage indexPage = new IndexPage(driver, url); LoginPage loginPage = indexPage.Header.ClickOnSignIn(); loginPage.Login(testUser.Email, testUser.Password); PaymentOptionsHomePage paymentsPage = indexPage.Header.ClickOnPaymentOptions(); PaymentOptionsCreatePage addPaymentPage = paymentsPage.ClickOnAddNewCreditCard(); addPaymentPage.FillCardTokenForm(testCardtoken); addPaymentPage.SelectBillingAddressOption(BillingAddressOptionsEnum.AddNew); addPaymentPage.SetInputAddressValue(AddressInputs.Country, testBillingAddress.country); addPaymentPage.SetInputAddressValue(AddressInputs.CompanyName, testBillingAddress.CompanyName); addPaymentPage.SetInputAddressValue(AddressInputs.Street, testBillingAddress.street); addPaymentPage.SetInputAddressValue(AddressInputs.Apartment, testBillingAddress.apartment); addPaymentPage.SetInputAddressValue(AddressInputs.City, testBillingAddress.city); addPaymentPage.SetInputAddressValue(AddressInputs.State, testBillingAddress.state); addPaymentPage.SetInputAddressValue(AddressInputs.Postal, testBillingAddress.postal); addPaymentPage.ClickOnSubmit(); addPaymentPage.IsAppBusy(); paymentsPage = addPaymentPage.CloseModal(ModalsEnum.Information); //begin the test paymentsPage.ClickOnPaymentOption(AccessLevel.User, selectPayment); PaymentOptionsEditPage editPaymentsPage = paymentsPage.ContentModal.ClickOnEdit(); bool makeDefaultCheckboxExist = editPaymentsPage.ElementOnPageIsPresent(AddPaymentElements.DefaultCheckbox); Assert.IsTrue(makeDefaultCheckboxExist, "Default checkbox does not exist"); editPaymentsPage.ClickOnMakeDefault(); bool isSubmitEnabled = editPaymentsPage.IsSubmitButtonEnabled(); Assert.IsTrue(isSubmitEnabled, "The form cannot be submited"); editPaymentsPage.ClickOnSubmit(); editPaymentsPage.IsAppBusy(); paymentsPage = editPaymentsPage.CloseModal(ModalsEnum.Information); List <string> items = paymentsPage.GetPaymentsDropdownItems(AccessLevel.User).ToList(); string payment = items.FirstOrDefault(it => it.Contains( $"{testCardtoken.LastFourDigits} {testCardtoken.ExpirationMont}/{testCardtoken.ExpirationYear}")); bool defaultLabelInDropdownItem = paymentsPage.IsDefaultLabelPresentOnDropdownItem(AccessLevel.User); string actualDefaultPaymentData = paymentsPage.GetDefaultTilePaymentData(AccessLevel.User); Assert.IsTrue(defaultLabelInDropdownItem, "Default label does not exist"); Assert.IsTrue(actualDefaultPaymentData.Contains(testCardtoken.LastFourDigits), "Card last four digits cannot be found"); Assert.IsTrue(actualDefaultPaymentData.Contains($"{testCardtoken.ExpirationMont}/{testCardtoken.ExpirationYear}"), "Expiration date does not correspond"); Assert.IsNotNull(payment, "Payment is not found"); }