public void RemoveFromCartTest(IEnumerable <string> links) { foreach (var link in links) { ProductPage product = new ProductPageBuilder(_driver).SetProductLink(link).Build(); product.Open(); product.AcceptCookies(); product.AddToCart(); } CartPage cart = new CartPage(_driver); cart.Open(); List <Product> cartProducts = cart.Products.ToList(); Assert.Equal(links.Count(), cartProducts.Count); for (int i = links.Count(); i > 0; i--) { Assert.Equal(cartProducts.Sum(x => x.Subtotal), cart.Subtotal); cartProducts[0].Remove(); cartProducts = cart.Products.ToList(); Assert.Equal(i, cartProducts.Count); } cartProducts = cart.Products.ToList(); Assert.Empty(cartProducts); }
public void RemoveFromCartTest(IEnumerable <string> links) { List <ProductInfo> productsInfo = new(); foreach (var link in links) { ProductPage product = new ProductPageBuilder(driver).SetProductLink(link).Build(); product.Open(); product.AcceptCookies(); productsInfo.Add((ProductInfo)product); product.AddToCart(); } CartPage cart = new CartPage(driver); cart.Open(); List <ProductInCart> cartProducts = cart.Products.ToList(); Assert.Equal(links.Count(), cartProducts.Count); //remove one product in cart by step for (int i = 0; i < links.Count(); i++) { Assert.Equal(cartProducts.Sum(x => x.Subtotal), cart.Subtotal, 1); Assert.Equal(productsInfo[i], (ProductInfo)cart.Products.ToList()[0]); cartProducts[0].Remove(); cartProducts = cart.Products.ToList(); } cartProducts = cart.Products.ToList(); Assert.Empty(cartProducts); }
public void ShippingInfoValidationTest(ShippingInfoValidationTestData data) { ProductPage product = new ProductPageBuilder(driver).SetProductLink(data.Link).Build(); product.Open(); product.AcceptCookies(); ShippingPage shippingPage = product.AddToCart().OpenCart().Checkout().Login(data.UserInfo ?? new User() { loginOption = LoginOption.Guest }); _mapper.Map(data.Info, shippingPage); bool hasValidationErrors; shippingPage.Next(out hasValidationErrors); Assert.Equal(data.HasValidationErrors, hasValidationErrors); }
public void SaveCartFromGuestUserTest(SaveCartFromGuestUserTestDataModel model) { //prepare - login, clear cart and logout HomePage page = new HomePage(driver); page.Open(); page.AcceptCookies(); page.OpenSignInPage().Login(model.LoginData); CartPage cartPage = new CartPage(driver); cartPage.Open(); cartPage.ClearCart().LogOut(); //add products from guest foreach (var link in model.Links) { ProductPage product = new ProductPageBuilder(driver).SetProductLink(link).Build(); product.Open(); product.AcceptCookies(); product.AddToCart(); } //save products in guest cart page = new HomePage(driver); page.Open(); cartPage = new CartPage(driver); cartPage.Open(); List <ProductInfo> guestCart = cartPage.Products.Select(x => (ProductInfo)x).ToList(); //login and save product in user cart cartPage.OpenSignInPage().Login(model.LoginData); cartPage = new CartPage(driver); cartPage.Open(); List <ProductInfo> userCart = cartPage.Products.Select(x => (ProductInfo)x).ToList(); Assert.True(Enumerable.SequenceEqual(guestCart, userCart)); cartPage.ClearCart(); }
public void CouponTest(CouponTestDataModel model) { foreach (var link in model.Links) { ProductPage product = new ProductPageBuilder(driver).SetProductLink(link).Build(); product.Open(); product.AcceptCookies(); product.AddToCart(); } CartPage cartPage = new CartPage(driver); cartPage.Open(); bool isCouponValid; cartPage.EnterCoupon(model.Coupon, out isCouponValid); Assert.Equal(model.IsCouponValid, isCouponValid); }
//[InlineData("https://www.dell.com/en-us/shop/dell-ultrasharp-32-8k-monitor-up3218k/apd/210-alez/monitors-monitor-accessories")] //[InlineData("https://www.dell.com/en-us/shop/dell-laptops/new-dell-g7-17-gaming-laptop/spd/g-series-17-7700-laptop/gn7700ehyyh")] //[InlineData("https://www.dell.com/en-us/shop/new-alienware-low-profile-rgb-mechanical-gaming-keyboard-aw510k/apd/580-aimo/pc-accessories")] //[InlineData("https://www.dell.com/en-us/shop/desktop-computers/new-inspiron-24-5000-black-all-in-one-with-bipod-stand/spd/inspiron-24-5400-aio/na5400ekphh")] //[InlineData("https://www.dell.com/en-us/shop/desktop-computers/inspiron-desktop/spd/inspiron-3880-desktop/nd3880eejks")] //[InlineData("https://www.dell.com/en-us/shop/dell-urban-backpack-15/apd/460-bbyl/carrying-cases")] //[InlineData("https://www.dell.com/en-us/shop/kensington-ld4650p-usb-c-universal-dock-with-k-fob-smart-lock-docking-station-usb-c-gige-north-america/apd/aa659274/pc-accessories")] //[InlineData("https://www.dell.com/en-us/shop/dell-32-curved-gaming-monitor-s3220dgf/apd/210-atyt/monitors-monitor-accessories")] //[InlineData("https://www.dell.com/en-us/shop/pny-nvidia-quadro-rtx-6000-graphics-card-24-gb-gddr6-pcie-30-x16-4-x-displayport-usb-c/apd/aa413562/graphic-video-cards")] //[InlineData("https://www.dell.com/en-us/shop/samsung-98-inch-tv-2020-qled-8k-ultra-hd-hdr10-smart-tv-q900-series-qn98q900rbfxza/apd/ab168598/tv-home-theater")] public void AddingToCartTest(string link) { ProductPage product = new ProductPageBuilder(_driver).SetProductLink(link).Build(); product.Open(); product.AcceptCookies(); double productPagePrice = product.Price; string productPageTitle = product.Title; double addedToCartPageSubtotal = product.AddToCart().Subtotal; Assert.Equal(productPagePrice, addedToCartPageSubtotal); CartPage cart = new CartPage(_driver); cart.Open(); List <Product> cartProducts = cart.Products.ToList(); Assert.Single(cartProducts); Assert.Equal(1, cartProducts[0].Count); Assert.Equal(productPageTitle, cartProducts[0].Title); Assert.Equal(productPagePrice, cartProducts[0].Subtotal); }