public void AddingProductToCartFromWishListUser() { TestAction(() => { string currentTestName = "AddingProductToCartFromWishListUser"; log.Debug("Starting " + currentTestName + " Test;"); log.Debug("For user " + user.FirstName + user.LastName + ";"); HomePage home = new HomePage(driverForRun, false); SmallSleep(); ProductHandler handler = new ProductHandler(driverForRun, home); Product product = new Product(ProductCategories.Top_deals, 2, driverForRun); SmallSleep(); int counter = handler.GetContainerCounter(ProductContainer.Cart); int prodctsInCart = handler.CountProductsInContainer(ProductContainer.Cart, product); Assume.That(prodctsInCart <= 1, "Product already in cart, test will not proceed"); MidSleep(); handler.AddProductToContainer(ProductContainer.WishList, InterctionControlSet.Product_Title, product); Assert.That(handler.CountProductsInContainer(ProductContainer.WishList, product) == 1, "Product did not got to WishList"); MidSleep(); handler.AddProductToContainer(ProductContainer.Cart, InterctionControlSet.Container_Switch, product); MidSleep(); handler.RemoveProductFromContainer(ProductContainer.WishList, InterctionControlSet.From_container, product); Assert.That((prodctsInCart + 1) == handler.CountProductsInContainer(ProductContainer.Cart, product), "Product wasn't added properly"); Assert.That((counter + 1) == handler.GetContainerCounter(ProductContainer.Cart), "Conter wasn't updated properly"); }); }
public void AddingProductToCartUser() { TestAction(() => { string currentTestName = "AddingProductToCartUser"; log.Debug("Starting " + currentTestName + " Test;"); log.Debug("For user " + user.FirstName + user.LastName + ";"); HomePage home = new HomePage(driverForRun, false); SignInPage signin = new SignInPage(driverForRun); //bool isUserLogedIn = ValidateUser(user); Assume.That(signin.Login(user), "Failed login, test will not run"); SmallSleep(); //moved from ValidateUser() var element = driverForRun.FindElement(By.XPath("//button[contains(@class,'d-md-block')]/div[text()=' START BROWSING ']")); TestHelper.JSexecutorClick(element, driverForRun); Assume.That(ValidateUser(user), "Logged-in account is not a user"); SmallSleep(); ProductHandler handler = new ProductHandler(driverForRun, home); Product product = new Product(ProductCategories.Top_deals, 1, driverForRun); SmallSleep(); int counter = handler.GetContainerCounter(ProductContainer.Cart); int prodctsInCart = handler.CountProductsInContainer(ProductContainer.Cart, product); Assert.That(prodctsInCart < 1, "Selected product already in cart"); MidSleep(); handler.AddProductToContainer(ProductContainer.Cart, InterctionControlSet.Product_Details, product); MidSleep(); Assert.That((prodctsInCart + 1) == handler.CountProductsInContainer(ProductContainer.Cart, product), "Product wasn't added properly"); Assert.That((counter + 1) == handler.GetContainerCounter(ProductContainer.Cart), "Conter wasn't updated properly"); }); }
public void MovingProductFromCartToWishListUser() { TestAction(() => { string currentTestName = "MovingProductFromCartToWishListUser"; log.Debug("Starting " + currentTestName + " Test;"); log.Debug("For user " + user.FirstName + user.LastName + ";"); HomePage home = new HomePage(driverForRun, false); SmallSleep(); ProductHandler handler = new ProductHandler(driverForRun, home); Product product = new Product(ProductCategories.Top_deals, 2, driverForRun); SmallSleep(); try { int counterCart = handler.GetContainerCounter(ProductContainer.Cart); int prodctsInCart = handler.CountProductsInContainer(ProductContainer.Cart, product); int counterWishList = handler.GetContainerCounter(ProductContainer.WishList); int prodctsInWishList = handler.CountProductsInContainer(ProductContainer.WishList, product); Assume.That(prodctsInCart >= 1, "Product not in cart, test will not proceed"); Assume.That(prodctsInWishList < 1, "Product already in wishist, test will not proceed"); MidSleep(); handler.AddProductToContainer(ProductContainer.WishList, InterctionControlSet.Container_Switch, product); MidSleep(); Assert.That(handler.CountProductsInContainer(ProductContainer.WishList, product) == 1, "Product did not got to WishList"); Assert.That(handler.CountProductsInContainer(ProductContainer.Cart, product) == 0, "Product wasn't removed from cart properly"); Assert.That((counterCart - 1) == handler.GetContainerCounter(ProductContainer.Cart), "Cart Conter wasn't updated properly"); Assert.That((counterWishList + 1) == handler.GetContainerCounter(ProductContainer.WishList), "WishList Conter wasn't updated properly"); } //clean-up finally { handler.RemoveProductFromContainer(ProductContainer.WishList, InterctionControlSet.From_container, product); } }); }
public void AddingProductToWishListFromCartTest() { TestAction(() => { string currentTestName = "AddingProductToWishListFromCartTest"; log.Debug("Starting " + currentTestName + " Test;"); log.Debug("For user " + user.FirstName + user.LastName + ";"); HomePage home = new HomePage(driverForRun, false); SmallSleep(); ProductHandler handler = new ProductHandler(driverForRun, home); Product product = new Product(ProductCategories.Top_deals, 5, driverForRun); SmallSleep(); handler.AddProductToContainer(ProductContainer.Cart, InterctionControlSet.Product_Details, product); Assert.That(handler.CountProductsInContainer(ProductContainer.WishList, product) == 0, "Product alreadty in wishlist"); int counter = handler.GetContainerCounter(ProductContainer.WishList); MidSleep(); handler.AddProductToContainer(ProductContainer.WishList, InterctionControlSet.Container_Switch, product); Assert.That(handler.CountProductsInContainer(ProductContainer.WishList, product) == 1, "Product wasn't added properly to wishlist"); Assert.That((counter + 1) == handler.GetContainerCounter(ProductContainer.WishList), "Counter wasn't updated properly"); }); }
public void AddingExistingProductToCartUser() { TestAction(() => { string currentTestName = "AddingExistingProductToCartUser"; log.Debug("Starting " + currentTestName + " Test;"); log.Debug("For user " + user.FirstName + user.LastName + ";"); HomePage home = new HomePage(driverForRun, false); SmallSleep(); ProductHandler handler = new ProductHandler(driverForRun, home); Product product = new Product(ProductCategories.Top_deals, 1, driverForRun); SmallSleep(); int counter = handler.GetContainerCounter(ProductContainer.Cart); int prodctsInCart = handler.CountProductsInContainer(ProductContainer.Cart, product); Assume.That(prodctsInCart >= 1, "No such product in cart, test will not proceed"); MidSleep(); handler.AddProductToContainer(ProductContainer.Cart, InterctionControlSet.Product_Details, product); MidSleep(); Assert.That((prodctsInCart + 1) == handler.CountProductsInContainer(ProductContainer.Cart, product), "Product wasn't added properly"); Assert.That((counter + 1) == handler.GetContainerCounter(ProductContainer.Cart), "Conter wasn't updated properly"); }); }
public void AddingProductToWishListFromProductDetailsTest() { TestAction(() => { string currentTestName = "AddingProductToWishListFromProductDetailsTest"; log.Debug("Starting " + currentTestName + " Test;"); log.Debug("For user " + user.FirstName + user.LastName + ";"); HomePage home = new HomePage(driverForRun, false); //SignInPage signin = new SignInPage(driverForRun); //Assume.That(signin.Login(user), "Failed login, test will not run"); //Assume.That(ValidateUser(user), "Logged-in account is not a user"); SmallSleep(); ProductHandler handler = new ProductHandler(driverForRun, home); Product product = new Product(ProductCategories.Top_deals, 4, driverForRun); SmallSleep(); Assert.That(handler.CountProductsInContainer(ProductContainer.WishList, product) == 0, "Product alreadty in wishlist"); int counter = handler.GetContainerCounter(ProductContainer.WishList); MidSleep(); handler.AddProductToContainer(ProductContainer.WishList, InterctionControlSet.Product_Details, product); Assert.That(handler.CountProductsInContainer(ProductContainer.WishList, product) == 1, "Product wasn't added properly to wishlist"); Assert.That((counter + 1) == handler.GetContainerCounter(ProductContainer.WishList), "Counter wasn't updated properly"); }); }
//[Test] //[Category("MemberCreationTests")] //[Order(2)] //public void MemberCreationAcceptFromCart() //{ // TestAction(() => // { // string currentTestName = "MemberCreationAcceptFromCart"; // log.Debug("Starting " + currentTestName + " Test;"); // log.Debug("For user " + user.FirstName + user.LastName + ";"); // if (user.ExpResult == "Accept-FromCart") // { // MemberCreationAccept(user); // } // else // { // //Assume.That(false, "User is not from this test. Test will not run."); // return; // } // }); //} //[Test] //[Category("MemberCreationTests")] //[Order(3)] //public void MemberCreationAcceptFinishLater() //{ // TestAction(() => // { // string currentTestName = "MemberCreationAcceptFinishLater"; // log.Debug("Starting " + currentTestName + " Test;"); // log.Debug("For user " + user.FirstName + user.LastName + ";"); // if (user.ExpResult == "Accept-FinishLater") // { // MemberCreationAccept(user); // } // else // { // //Assume.That(false, "User is not from this test. Test will not run."); // return; // } // }); //} //[Test] //[Category("MemberCreationTests")] //[Order(4)] //public void MemberCreationRejectWrongZipCode() //{ // TestAction(() => // { // string currentTestName = "MemberCreationRejectWrongZipCode"; // log.Debug("Starting " + currentTestName + " Test;"); // log.Debug("For user " + user.FirstName + user.LastName + ";"); // if (user.ExpResult == "Reject-WrongZipCode") // { // MemberCreationReject(user); // } // else // { // //Assume.That(false, "User is not from this test. Test will not run."); // return; // } // }); //} //[Test] //[Category("MemberCreationTests")] //[Order(5)] //public void MemberCreationRejectUnsupportedState() //{ // TestAction(() => // { // string currentTestName = "MemberCreationRejectUnsupportedState"; // log.Debug("Starting " + currentTestName + " Test;"); // log.Debug("For user " + user.FirstName + user.LastName + ";"); // if (user.ExpResult == "Reject-UnsupportedState") // { // MemberCreationReject(user); // } // else // { // //Assume.That(false, "User is not from this test. Test will not run."); // return; // } // }); //} //[Test] //[Category("MemberCreationTests")] //[Order(6)] //public void MemberCreationRejectLowIncome() //{ // TestAction(() => // { // string currentTestName = "MemberCreationRejectLowIncome"; // log.Debug("Starting " + currentTestName + " Test;"); // log.Debug("For user " + user.FirstName + user.LastName + ";"); // if (user.ExpResult == "Reject-LowIncome") // { // MemberCreationReject(user); // } // else // { // //Assume.That(false, "User is not from this test. Test will not run."); // return; // } // }); //} private void MemberCreationAccept(TestUser user) { bool navigate = true; bool letsGetYourRentalCapMessageExpected = true; bool finishLater = false; switch (user.ExpResult) { case "Accept-FromLogIn": log.Debug("How to Invoke: from LogIn"); break; case "Accept-FromCart": log.Debug("How to Invoke: from Cart"); HomePage home = new HomePage(driverForRun); SmallSleep(); ProductHandler handler = new ProductHandler(driverForRun, home); Product product = new Product(ProductCategories.Top_deals, 1, driverForRun); SmallSleep(); handler.AddProductToContainer(ProductContainer.Cart, InterctionControlSet.Product_Details, product); wait = new WebDriverWait(driverForRun, TimeSpan.FromSeconds(10)); string btnBecomeMemberInCartXPath = "//button[text()='become a member']"; wait.Until(ExpectedConditions.ElementExists(By.XPath(btnBecomeMemberInCartXPath))); var btnBecomeMemberInCart = driverForRun.FindElement(By.XPath(btnBecomeMemberInCartXPath)); TestHelper.JSexecutorClick(btnBecomeMemberInCart, driverForRun); navigate = false; letsGetYourRentalCapMessageExpected = false; break; case "Accept-FinishLater": log.Debug("How to Invoke: from Finish Later - Become A Member"); finishLater = true; break; default: Assume.That(false, "User is not from this test. Test will not run."); break; } SignUpPage signUp = new SignUpPage(driverForRun, navigate); Assert.That(signUp.UserSignUp(user), "Sign Up failed"); if (letsGetYourRentalCapMessageExpected) { GetYourRentalCapButtonClick(); } MemberCreationFirstPage pagePersonalInfo = new MemberCreationFirstPage(driverForRun); if (finishLater) { MidSleep(); TestHelper.JSexecutorClick(pagePersonalInfo.btnFinishLater, driverForRun); Assert.IsTrue(ValidateUser(user), "User validation is Failed"); var btnBecomeMemberOnHome = driverForRun.FindElement(By.XPath("//button[text()='BECOME A MEMBER']")); TestHelper.JSexecutorClick(btnBecomeMemberOnHome, driverForRun); } pagePersonalInfo.SetPersonalInfo(user); MemberCreationSecondPage pageIncomeInfo = new MemberCreationSecondPage(driverForRun); pageIncomeInfo.SetIncomeInfo(user); MemberCreationThirdPage pageMembershipAgreement = new MemberCreationThirdPage(driverForRun); pageMembershipAgreement.SetMembershipAgreement(user); MemberCreationFourthPage pageApplicationDisclosure = new MemberCreationFourthPage(driverForRun); pageApplicationDisclosure.SetAgreement(); MemberCreationFifthPage pageCongratulations = new MemberCreationFifthPage(driverForRun); string rentExpectedValue = RentalCapExpected(user); string rentActualValue = pageCongratulations.GetRentalCapValue(); Assert.AreEqual(rentExpectedValue, rentActualValue); TestHelper.JSexecutorClick(pageCongratulations.btnStartShopping, driverForRun); Assert.IsTrue(rentExpectedValue == GetCurrentRentalCap(), "Rental Cap validation is Failed"); Assert.IsTrue(ValidateMember(user), "Member validation is Failed"); switch (user.ExpResult) { case "Accept-FromLogIn": Assert.Pass("User succesfully registered as member from login"); break; case "Accept-FromCart": Assert.Pass("User succesfully registered as member from product cart item"); break; case "Accept-FinishLater": Assert.Pass("User succesfully registered as member, by finishing registration later"); break; } }