示例#1
0
        public void AddCreditCardUsingNewAddress()
        {
            var testData = TestDataFactory.CreateLoginAccount();

            #region test data models
            var cardtoken = new PaymentOptionModel
            {
                CardNumber     = "5582508629687473",
                ExpirationMont = "12",
                ExpirationYear = "24",
                HolderName     = "Test corp",
                Cvv            = "077",
                LastFourDigits = "7473"
            };
            var address = new AddressModel
            {
                country     = "US",
                CompanyName = "QA Softtek Automation",
                state       = "CO",
                city        = "Denver",
                street      = "Elm street",
                postal      = "22780",
                apartment   = "24"
            };
            #endregion

            IndexPage indexPage = new IndexPage(driver, url);
            LoginPage loginPage = indexPage.Header.ClickOnSignIn();
            indexPage = loginPage.Login(testData.Email, testData.Password);

            PaymentOptionsHomePage   paymentsPage      = indexPage.Header.ClickOnPaymentOptions();
            PaymentOptionsCreatePage addNewPaymentPage = paymentsPage.ClickOnAddNewCreditCard();
            addNewPaymentPage.FillCardTokenForm(cardtoken);
            addNewPaymentPage.SelectBillingAddressOption(BillingAddressOptionsEnum.AddNew);

            //Fill billing address form
            addNewPaymentPage.SetInputAddressValue(AddressInputs.CompanyName, address.CompanyName);
            addNewPaymentPage.SetInputAddressValue(AddressInputs.Street, address.street);
            addNewPaymentPage.SetInputAddressValue(AddressInputs.Apartment, address.apartment);
            addNewPaymentPage.SetInputAddressValue(AddressInputs.City, address.city);
            addNewPaymentPage.SetInputAddressValue(AddressInputs.State, address.state);
            addNewPaymentPage.SetInputAddressValue(AddressInputs.Postal, address.postal);

            bool makeDefaultCheckboxExist = addNewPaymentPage.ElementOnPageIsPresent(AddPaymentElements.DefaultCheckbox);

            Assert.IsTrue(makeDefaultCheckboxExist, "Default checkbox does not exist");

            addNewPaymentPage.ClickOnSubmit();
            addNewPaymentPage.IsAppBusy();
            paymentsPage = addNewPaymentPage.CloseModal(ModalsEnum.Information);
            Thread.Sleep(1000);

            List <string> items   = paymentsPage.GetPaymentsDropdownItems(AccessLevel.User).ToList();
            string        payment = items.FirstOrDefault(it => it.Contains($"{cardtoken.LastFourDigits} {cardtoken.ExpirationMont}/{cardtoken.ExpirationYear}"));

            Assert.IsNotNull(payment, "Payment is not found");
        }
示例#2
0
        public void DeleteUserLevelPayment()
        {
            #region testData
            var testUser = TestDataFactory.CreateLoginAccount();
            PaymentOptionModel testCardtoken = new PaymentOptionModel
            {
                CardNumber     = "5582508629687473",
                ExpirationMont = "12",
                ExpirationYear = "24",
                HolderName     = "Test corp",
                Cvv            = "077",
                LastFourDigits = "7473"
            };
            AddressModel testAddress = new AddressModel
            {
                country     = "US",
                CompanyName = "QA Softtek Automation",
                state       = "CO",
                city        = "Denver",
                street      = "Elm street",
                postal      = "22780",
                apartment   = "24"
            };
            #endregion testData

            IndexPage indexPage = new IndexPage(driver, url);
            LoginPage loginPage = indexPage.Header.ClickOnSignIn();
            indexPage = loginPage.Login(testUser.Email, testUser.Password);

            Assert.IsNotNull(indexPage, "Login failed");

            PaymentOptionsHomePage   paymentsPage      = indexPage.Header.ClickOnPaymentOptions();
            PaymentOptionsCreatePage addNewPaymentPage = paymentsPage.ClickOnAddNewCreditCard();
            addNewPaymentPage.FillCardTokenForm(testCardtoken);
            addNewPaymentPage.ClickOnBillingAddressOption(BillingAddressOptions.NewOne);

            //Fill billing address form
            addNewPaymentPage.SetInputAddressValue(AddressInputs.CompanyName, testAddress.CompanyName);
            addNewPaymentPage.SetInputAddressValue(AddressInputs.Street, testAddress.street);
            addNewPaymentPage.SetInputAddressValue(AddressInputs.Apartment, testAddress.apartment);
            addNewPaymentPage.SetInputAddressValue(AddressInputs.City, testAddress.city);
            addNewPaymentPage.SetInputAddressValue(AddressInputs.State, testAddress.state);
            addNewPaymentPage.SetInputAddressValue(AddressInputs.Postal, testAddress.postal);

            bool makeDefaultCheckboxExist = addNewPaymentPage.ElementOnPageIsPresent(AddPaymentElements.DefaultCheckbox);

            Assert.IsTrue(makeDefaultCheckboxExist, "Default checkbox does not exist");

            addNewPaymentPage.ClickOnSubmit();
            addNewPaymentPage.IsAppBusy();
            paymentsPage = addNewPaymentPage.CloseModal(ModalsEnum.Information);
            Thread.Sleep(1000);

            //start deleting the payment
            int paymentsCountBefore = paymentsPage.GetPaymentsDropdownItems(AccessLevel.User).ToList().Count;

            paymentsPage.ClickOnPaymentOption(
                AccessLevel.User,
                $"{testCardtoken.LastFourDigits} {testCardtoken.ExpirationMont}/{testCardtoken.ExpirationYear}");

            Thread.Sleep(2000);
            paymentsPage.ContentModal.ClickOnDelete();
            Thread.Sleep(1000);
            paymentsPage.ConfirmationModal.ClickOnDelete();
            paymentsPage.IsAppBusy();

            int paymentsCountAfter = paymentsPage.GetPaymentsDropdownItems(AccessLevel.User).ToList().Count;

            Assert.IsTrue(paymentsCountAfter == (paymentsCountBefore - 1), "Payment has not deleted");
        }