Example #1
0
        //Test Case on test rail -> C1134, C1135, C1179
        //[TestMethod]
        //[TestCategory(TestCategoriesConstants.Regression)]
        //[TestCategory(TestCategoriesConstants.Smoke)]
        public void AddCreditCardUsingPrevStoredAddress()
        {
            var          testData    = TestDataFactory.CreateLoginAccount();
            AddressModel testAddress = new AddressModel
            {
                country     = "US",
                street      = "street test",
                CompanyName = "address company name",
                state       = "CO",
                city        = "boulder",
                postal      = "52809"
            };
            PaymentOptionModel testCardtoken = new PaymentOptionModel
            {
                CardNumber     = "4111111111111111",
                ExpirationMont = "12",
                ExpirationYear = "22",
                HolderName     = "Test holder",
                Cvv            = "077",
                LastFourDigits = "1111"
            };

            IndexPage indexPage = new IndexPage(driver, url);
            LoginPage loginPage = indexPage.Header.ClickOnSignIn();

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

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

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

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

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

            string storedAddress = string.IsNullOrEmpty(testAddress.apartment) ?
                                   $"{testAddress.street}, {testAddress.city} {testAddress.country} {testAddress.postal}"
                :
                                   $"{testAddress.street}, {testAddress.apartment}, {testAddress.city} {testAddress.country} {testAddress.postal}";

            addNewPaymentPage.FillCardTokenForm(testCardtoken);
            addNewPaymentPage.SelectBillingAddressOption(BillingAddressOptionsEnum.Stored);
            addNewPaymentPage.SelectPreviouslyStoreAddress(storedAddress);
            addNewPaymentPage.ClickOnSubmit();
            addNewPaymentPage.IsAppBusy();
            paymentsPage = addNewPaymentPage.CloseModal(ModalsEnum.Information);
            addNewPaymentPage.IsAppBusy();
            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");
        }
Example #2
0
        public void E2E05()
        {
            APIndexPage indexPage = new APIndexPage(Driver, Url);

            // log in
            APLoginPage loginPage = indexPage.Header.ClickOnSignIn();

            loginPage.Login("*****@*****.**", "test1234");

            DashboardHomePage accountDashboard = indexPage.Header.ClickOnDashboard();

            Assert.IsTrue(accountDashboard.ContactInfoExist());

            ContactInfoEditPage contactInfoEdit = accountDashboard.ContactInfoEdit();

            Assert.AreEqual("Edit contact information", contactInfoEdit.GetSectionTitle());
            contactInfoEdit.ClickOnCancel();

            Assert.IsTrue(accountDashboard.AddressesExist());

            AddressesHomePage addressPage = accountDashboard.ClickAddressesLink();

            AddressModel addressModel = new AddressModel
            {
                street      = "134 Manton Street",
                apartment   = "134",
                state       = "Pennsylvania",
                city        = "Philadelphia",
                postal      = "19147",
                country     = "US",
                region      = "PA",
                CompanyName = "Test company"
            };

            addressPage.ClickOnAddressInDropdownStateInitials(AccessLevel.User, addressModel);
            addressPage.WaitForAppBusy();
            addressPage.ContentModal.ClickOnCancel();
            addressPage.WaitForAppBusy();

            /**/
            AddAddressPage addAddressPage = addressPage.ClickOnAddNewAddress();

            AddressModel newAddressModel = new AddressModel
            {
                street      = "134 Testing Street",
                apartment   = "134",
                state       = "Colorado",
                city        = "Aspen",
                postal      = "12345",
                country     = "US",
                region      = "CO",
                CompanyName = "Test company"
            };

            addAddressPage.SetInputValue(PageObjects.MyAccountPOM.AddressesPOM.AddressInputs.Country, newAddressModel.country);
            addAddressPage.SetInputValue(PageObjects.MyAccountPOM.AddressesPOM.AddressInputs.CompanyName, newAddressModel.CompanyName);
            addAddressPage.SetInputValue(PageObjects.MyAccountPOM.AddressesPOM.AddressInputs.Street, newAddressModel.street);
            addAddressPage.SetInputValue(PageObjects.MyAccountPOM.AddressesPOM.AddressInputs.Apartment, newAddressModel.apartment);
            addAddressPage.SetInputValue(PageObjects.MyAccountPOM.AddressesPOM.AddressInputs.City, newAddressModel.city);
            addAddressPage.SetInputValue(PageObjects.MyAccountPOM.AddressesPOM.AddressInputs.State, newAddressModel.state);
            addAddressPage.SetInputValue(PageObjects.MyAccountPOM.AddressesPOM.AddressInputs.Postal, newAddressModel.postal);

            addressPage = addAddressPage.ClickOnSubmit();
            addAddressPage.InformationModal.ClickOnClose();
            addressPage.WaitForAppBusy();


            addressPage.ClickOnAddressInDropdownStateInitials(AccessLevel.User, addressModel);
            addressPage.WaitForAppBusy();

            addressPage.ContentModal.ClickOnMakeDefault();
            addressPage.WaitForAppBusy();
            //TEMPORARY SOLUTION FOR LOADING ANIMATIONS AND LOADING TIMES
            System.Threading.Thread.Sleep(3000);

            addressPage.InformationModal.ClickOnClose();

            /*
             */

            accountDashboard = addressPage.Header.ClickOnDashboard();

            accountDashboard.WaitForAppBusy();
            Assert.IsTrue(accountDashboard.PaymentOptionsExist());

            PaymentOptionsEditPage paymentEditPage = accountDashboard.ClickEditPaymentLink();

            paymentEditPage.ClickOnCancel();

            PaymentOptionsHomePage paymentPage = accountDashboard.ClickPaymentsLink();

            Assert.IsTrue(paymentPage.PaymentOptionsTitleExist());
            IEnumerable <String> paymentItems = paymentPage.GetPaymentsDropdownItems(AccessLevel.Account);

            paymentPage.ClickOnPaymentOption(AccessLevel.Account, paymentItems.First());
            paymentPage.WaitForAppBusy();
            paymentPage.ContentModal.ClickOnMakeDefault();
            paymentPage.WaitForAppBusy();
            paymentPage.InfoModal.ClickOnClose();

            paymentItems = paymentPage.GetPaymentsDropdownItems(AccessLevel.User);

            paymentPage.ClickOnPaymentOption(AccessLevel.User, paymentItems.First());
            paymentPage.WaitForAppBusy();
            paymentPage.ContentModal.ClickOnMakeDefault();
            paymentPage.WaitForAppBusy();
            // TEMPORARY SOLUTION SO IFRAME LOADS AND DOM ELEMENT WAIT DOESN'T CRASH/FAIL THE TEST
            // *** FUTURE SOLUTION TO DO
            System.Threading.Thread.Sleep(4000);
            paymentPage.InfoModal.ClickOnClose();

            paymentPage.WaitForAppBusy();
            PaymentOptionsCreatePage paymentCreatePage = paymentPage.ClickOnAddNewCreditCard();

            // TEMPORARY SOLUTION SO IFRAME LOADS AND DOM ELEMENT WAIT DOESN'T CRASH/FAIL THE TEST
            // *** FUTURE SOLUTION TO DO
            System.Threading.Thread.Sleep(5000);

            PaymentOptionModel paymentOptionModel = new PaymentOptionModel
            {
                CardNumber     = "4111111111111111",
                ExpirationMont = "12",
                ExpirationYear = "2022",
                Cvv            = "077",
                HolderName     = "Test Test",
                LastFourDigits = "1293"
            };

            paymentCreatePage.WaitForAppBusy();
            paymentCreatePage.FillCardTokenForm(paymentOptionModel);
            paymentCreatePage.ClickOnMakeDefault();
            paymentCreatePage.SelectPreviouslyStoreAddress("Test company");
            paymentCreatePage.ClickOnSubmit();
            System.Threading.Thread.Sleep(3000);

            // assert if click on submit is valid ( assert/bool that all fields are valid)
            // if assert for click on submit is valid then assert modal if creditcard was a succesfully added
            paymentPage = paymentCreatePage.CloseModal(ModalsEnum.Information);

            // TEMPORARY SOLUTION
            System.Threading.Thread.Sleep(3000);

            // step to change to a US adress and change state to colorado
            // this before searching for item


            //
            indexPage.Header.SetSearchFieldText("KE50750-4");
            CatalogItemsPage catalogItemsPage = indexPage.Header.ClickOnSearchButton();

            catalogItemsPage.AddToCartFirstItemInCatalog();

            APCartPage cartPage = indexPage.Header.ClickOnViewCart();

            // TEMPORARY SOLUTION
            System.Threading.Thread.Sleep(6000);
        }