Esempio n. 1
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");
        }