コード例 #1
0
        public void E2E02()
        {
            APIndexPage indexPage = new APIndexPage(Driver, Url);

            Login(indexPage);

            //Click on a Top Level Category (e.g.Hardware & Supplies)
            CatalogItemsPage catalogItemsPage = indexPage.Header.ClickOnCategory("Hardware & Supplies");

            Assert.IsTrue(catalogItemsPage.CheckIfYourPriceIsDisplayed(), "Your price is not diplayed");

            //Product list views
            catalogItemsPage.AddToCartElementByIndex(0);
            catalogItemsPage.ClickOnListViewIcon();
            catalogItemsPage.AddToCartElementByIndex(2);
            Assert.IsTrue(catalogItemsPage.ListViewDisplayed(), "The product view was not updated to List view(stack view).");

            //Page Navigation
            catalogItemsPage = catalogItemsPage.ClickOnNextPage();
            Assert.AreEqual("2", catalogItemsPage.GetActualPageListNumber(), "The page list number must be '2'.");
            catalogItemsPage.AddToCartElementByIndex(0);
            catalogItemsPage = catalogItemsPage.ClickOnLastPage();
            Assert.AreEqual(catalogItemsPage.GetLastPageListNumber(), catalogItemsPage.GetActualPageListNumber(), "Last page must be diplayed.");
            catalogItemsPage.AddToCartElementByIndex(0);

            //Category Navigation
            catalogItemsPage = catalogItemsPage.ClickOnSubCategory("Buzzers");
            catalogItemsPage.AddToCartFirstItemInCatalog();

            //Cart & Save for Later
            APCartPage cartPage = catalogItemsPage.Header.ClickOnViewCart();

            //Assert.AreEqual(5, cartPage.GetNumberOfItemsInCart(), "Must be 5 items in cart");
            Assert.IsTrue(cartPage.TotalAmountIsCorrect(), "The total amount doesn't reflect the sum of the items total.");
            cartPage.SelectAllItems();
            Assert.AreEqual(cartPage.GetNumberOfItemsInCart(), cartPage.GetNumberOfSelectedItems(), "Not all items were selected.");
            cartPage.MoveSelectedToSaveLater();
            Assert.AreEqual(0, cartPage.GetNumberOfItemsInCart(), "All items must be moved to 'Save for later' tab");
            cartPage.ClickOnSavedForLater();
            cartPage.SelectItemsByIndex(0);
            cartPage.SelectItemsByIndex(1);
            cartPage.SelectItemsByIndex(2);
            cartPage.MoveSelectedToCart();
            cartPage.ClickIndividualMoveToCartByIndex(1);
            cartPage.ClickOnCartTab();
            Assert.AreEqual(4, cartPage.GetNumberOfItemsInCart(), "Number of items in cart must be 4.");
            Assert.IsTrue(cartPage.InventoryAvailabilityIsDisplayed(), "Inventory availability must be displayed.");
            cartPage.SelectItemsByIndex(0);
            cartPage.SelectItemsByIndex(1);
            cartPage.ClickRemoveSelectedItems();
            cartPage.RemoveIndividualItemByIndex(0);
            Assert.AreEqual(1, cartPage.GetNumberOfItemsInCart(), "Number of items in cart must be 1.");

            //Checkout and continue shopping
            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();
            OrderConfirmationPage orderConfirmationPage = checkoutPage.PlaceOrderSubmitClick();

            orderConfirmationPage.ClickOnContinueShoppingButton(ContinueShoppingButtons.ContinueShopping);
        }
コード例 #2
0
        public void E2E01()
        {
            //Search & Price
            APIndexPage indexPage = new APIndexPage(Driver, Url);

            indexPage.Header.SetSearchFieldText("103-1035");
            CatalogItemsPage catalogItemsPage = indexPage.Header.ClickOnSearchButton();

            //Add product to the cart from the result page
            Assert.IsTrue(catalogItemsPage.IsListPriceDisplayed(), "There is no numeric price shown.");
            int quantityBeforeAdd = catalogItemsPage.Header.GetMiniCartQuantity();

            catalogItemsPage.AddToCartElementByIndex(0);
            int quantityAfterAdd = catalogItemsPage.Header.GetMiniCartQuantity(quantityBeforeAdd);
            //Assert.IsTrue(quantityAfterAdd > quantityBeforeAdd, "The item quantity did no increment");

            //Click on the product to go to the Product Detail Page
            OfferingProductsPage offeringProductsPage = catalogItemsPage.ClickOnFirstItemInCatalog();

            Assert.IsTrue(offeringProductsPage.ListPriceLabelforANON(), "List price tag not shown.");
            Assert.IsTrue(offeringProductsPage.NumericPriceDisplayed(), "No numeric price diplayed.");
            offeringProductsPage.UpdateAmountQuantity();
            int amountQuantityBeforeAdd = offeringProductsPage.GetAmountQuantity();

            //Add product to the cart from Product Detail Page and click on cart
            offeringProductsPage.AddToCartFirstProduct();
            offeringProductsPage.UpdateAmountQuantity();
            int amountQuantityAfterAdd = offeringProductsPage.GetAmountQuantity();

            Assert.IsTrue(offeringProductsPage.AumontQuantityIncremented(amountQuantityBeforeAdd, amountQuantityAfterAdd),
                          "Quantity did not incremented.");
            APCartPage cartPage = offeringProductsPage.ClickOnCart();

            Assert.AreEqual(1, cartPage.NumberOfItemsInCart(), "Should be just one product in cart.");
            Assert.AreEqual(2, cartPage.GetQuantityInput(), "Quantity must be 2.");

            //Checkout
            cartPage.ProceedToCheckOut();
            APCheckoutPage   checkoutPage     = cartPage.CheckoutAsGuest();
            ContactInfoModel contactInfoModel = new ContactInfoModel();

            contactInfoModel.FirstName   = "Jesus Carlos";
            contactInfoModel.LastName    = "Acosta Rocha";
            contactInfoModel.Email       = "*****@*****.**";
            contactInfoModel.Company     = "Softtek";
            contactInfoModel.PhoneNumber = "6681596072";
            checkoutPage.SetContactElement(ContactInputs.FirstName, contactInfoModel.FirstName);
            checkoutPage.SetContactElement(ContactInputs.LastName, contactInfoModel.LastName);
            checkoutPage.SetContactElement(ContactInputs.Email, contactInfoModel.Email);
            checkoutPage.SetContactElement(ContactInputs.Company, contactInfoModel.Company);
            checkoutPage.SetContactElement(ContactInputs.PhoneNumber, contactInfoModel.PhoneNumber);
            checkoutPage.NextStep();
            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.NextStep();
            SetCreditCard(checkoutPage);
            checkoutPage.NextStep();

            //Confirmation page and continue shopping
            OrderConfirmationPage orderConfirmationPage = checkoutPage.PlaceOrderSubmitClick();

            orderConfirmationPage.ClickOnContinueShoppingButton(ContinueShoppingButtons.PrintOrderConfirmation);
            Assert.AreEqual(2, Driver.WindowHandles.Count, "Printable Order Confirmation Not Shown.");
            Driver.SwitchTo().DefaultContent();
            orderConfirmationPage.ClickOnContinueShoppingButton(ContinueShoppingButtons.ContinueShopping);
        }