예제 #1
0
        public void E2E03()
        {
            //Content
            APIndexPage indexPage = new APIndexPage(Driver, Url);

            Login(indexPage);

            //Shopping lists
            OfferingProductsPage offeringProductsPage = indexPage.ClickOnProductSpotlightDealsByIndex(0);

            offeringProductsPage.ClickOnAddToList();
            Assert.AreEqual(1, offeringProductsPage.AddListModal.GetOptionsFromChooseListModal().Count,
                            "There must be just 1 option.");
            Assert.AreEqual("My List", offeringProductsPage.AddListModal.GetOptionsFromChooseListModal()[0].webElement.Text,
                            "The option must be 'My List'");
            offeringProductsPage.AddListModal.CloseAddToListModal();
            offeringProductsPage.ClickOnAddToList();
            offeringProductsPage.AddListModal.ClickOnAddToListModal();
            offeringProductsPage.AddListModal.IsSuccessMessageInModal();
            offeringProductsPage.AddListModal.CloseAddToListModal();

            //Shopping lists
            offeringProductsPage.ChangeQuantity(2);
            offeringProductsPage.UpdateAmountQuantity();
            int amountQuantityBeforeAdd = offeringProductsPage.GetAmountQuantity();

            offeringProductsPage.AddToCartFirstProduct();
            offeringProductsPage.UpdateAmountQuantity();
            int amountQuantityAfterAdd = offeringProductsPage.GetAmountQuantity();

            Assert.IsTrue(offeringProductsPage.AumontQuantityIncremented(amountQuantityBeforeAdd, amountQuantityAfterAdd),
                          "Quantity did not increment.");
            offeringProductsPage.ScrollToTop();
            offeringProductsPage.WaitForAppBusy(3);
            offeringProductsPage.Header.SetSearchFieldText("Amana");
            CatalogItemsPage catalogItemsPage = offeringProductsPage.Header.ClickOnSearchButton();

            catalogItemsPage.AddToListByIndex(0);
            catalogItemsPage.AddToListByIndex(1);
            catalogItemsPage.AddToListByIndex(2);
            APListSummaryPage listSummaryPage = catalogItemsPage.AddToListByIndex(3, visitList: true);

            Assert.AreEqual(5, listSummaryPage.NumberOfItemsInList(), "Quantity must be 5.");
            listSummaryPage.SelectByIndex(0);
            listSummaryPage.SelectByIndex(1);
            listSummaryPage.ClickOnRemoveSelected();
            Assert.AreEqual(3, listSummaryPage.NumberOfItemsInList(), "Quantity must be 3.");
            listSummaryPage.RemoveIndividualByIndex(0);
            Assert.AreEqual(2, listSummaryPage.NumberOfItemsInList(), "Quantity must be 2.");
            // if different in cart is true, it clicks on a different index
            listSummaryPage.ClickOnAddToCartByIndex(1, differentInCart: true);
            //*******************
            APListHomePage listHomePage = listSummaryPage.ClickOnBreadCrumbLists();

            listHomePage.ClickCreateaNewList();
            listHomePage.SendListName("new list");
            listHomePage.ClickCreateListButton();
            Assert.IsTrue(listHomePage.SuccessListCreated(), "List was not created");
            listHomePage.CloseModal();
            catalogItemsPage = listHomePage.Header.ClickOnCategory("Hardware & Supplies");
            listSummaryPage  = catalogItemsPage.AddToListByIndex(0, visitList: true, list: "new list");
            Assert.AreEqual(1, listSummaryPage.NumberOfItemsInList(), "There must be 1 item.");
            listHomePage = listSummaryPage.ClickOnBreadCrumbLists();
            Assert.AreEqual(2, listHomePage.GetNumberOfLists());

            //Create new payment method at checkout
            APCartPage cartPage = listHomePage.Header.ClickOnViewCart();

            Assert.AreEqual(2, cartPage.GetNumberOfItemsInCart());
            cartPage.GetQuantityInput();
            Assert.IsTrue(cartPage.IsQuantityInCartItem(2), "One of the quantity items must be 1.");
            APCheckoutPage checkoutPage = cartPage.ProceedToCheckOut();

            checkoutPage.UserInfoIsPopulated();
            AddressModel addressModel = GetAddressModel();

            checkoutPage.SetAddressElement(AddressInputs.StreetAddress, addressModel.street);
            checkoutPage.SetAddressElement(AddressInputs.City, addressModel.city);
            checkoutPage.SetAddressElement(AddressInputs.State, addressModel.state);
            checkoutPage.SetAddressElement(AddressInputs.Postal, addressModel.postal);
            checkoutPage.SetAddressElement(AddressInputs.ATTN, "Tundra Restaurant Supply");
            checkoutPage.NextStep();
            checkoutPage.ClickEditAction(EditActions.SecureBillingInformation);
            checkoutPage.ClickOnAssingNewCard();
            SetCreditCard(checkoutPage);
            checkoutPage.NextStep();
            OrderConfirmationPage orderConfirmationPage = checkoutPage.PlaceOrderSubmitClick();

            orderConfirmationPage.ClickOnContinueShoppingButton(ContinueShoppingButtons.ContinueShopping);
        }