コード例 #1
0
        public void AddCreditCardUsingPrevStoredAddress()
        {
            var         testData    = DataFactory.Users.CreateTestUser();
            TestAddress testAddress = new TestAddress
            {
                Country             = "US",
                Street              = "street test",
                Name                = "address company name",
                StateProvinceRegion = "CO",
                City                = "boulder",
                Postal              = "52809"
            };
            PaymentOptionModel testCardtoken = new PaymentOptionModel
            {
                CardNumber     = "4111111111111111",
                ExpirationMont = "12",
                ExpirationYear = "22",
                HolderName     = "Test holder",
                Cvv            = "077",
                LastFourDigits = "1111"
            };

            APIndexPage indexPage = new APIndexPage(Driver, Url);
            APLoginPage loginPage = indexPage.Header.ClickOnSignIn();

            indexPage = loginPage.Login(testData.Username, testData.Password);

            //Manually add an address
            AddressesHomePage addressesPage     = indexPage.Header.ClickOnAddresses();
            AddAddressPage    createAddressPage = addressesPage.ClickOnAddNewAddress();

            //Fill address form
            createAddressPage.SetInputValue(AddressInputs.CompanyName, testAddress.Name);
            createAddressPage.SetInputValue(AddressInputs.Street, testAddress.Street);
            createAddressPage.SetInputValue(AddressInputs.Apartment, testAddress.Apartment);
            createAddressPage.SetInputValue(AddressInputs.City, testAddress.City);
            createAddressPage.SetInputValue(AddressInputs.State, testAddress.StateProvinceRegion);
            createAddressPage.SetInputValue(AddressInputs.Postal, testAddress.Postal);

            addressesPage = createAddressPage.ClickOnSubmit();
            addressesPage.WaitForAppBusy();
            //TODO: check the logic on address create process
            addressesPage.WaitForAppBusy();
            addressesPage.InformationModal.ClickOnClose();

            //test begins here
            PaymentOptionsHomePage   paymentsPage      = addressesPage.Header.ClickOnPaymentOptions();
            PaymentOptionsCreatePage addNewPaymentPage = paymentsPage.ClickOnAddNewCreditCard();

            addNewPaymentPage.FillCardTokenForm(testCardtoken);
            addNewPaymentPage.SelectBillingAddressOption(BillingAddressOptionsEnum.Stored);
            addNewPaymentPage.SelectPreviouslyStoredAddress(testAddress);
            addNewPaymentPage.ClickOnSubmit();
            addNewPaymentPage.WaitForAppBusy();
            paymentsPage = addNewPaymentPage.CloseModal(ModalsEnum.Information);
            addNewPaymentPage.WaitForAppBusy();
            Thread.Sleep(500);

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

            Assert.IsNotNull(payment, "Payment option is not found");
        }