示例#1
0
        public static void AddProductsToCart()
        {
            ChewablesPageObjects cpo = new ChewablesPageObjects();

            ChewablesOrderPageObjects copo = new ChewablesOrderPageObjects();

            NavigationActions.NavigateOurProductsChewablesClick();
            Task.Delay(500).Wait(1500);

            cpo.ScrollViewport();
            cpo.ShopNowPremiumChewables.Click();
            Assert.IsTrue(Driver.WebDriver.PageSource.Contains("Premium Soft Chewables"));
            cpo.ScrollViewport();
            copo.AddToCartOrder.Click();
            Thread.Sleep(1000);
        }
示例#2
0
        public static void AddBerryChewablesToCart()
        {
            WebDriverWait waitForElement     = new WebDriverWait(Driver.WebDriver, TimeSpan.FromSeconds(30));
            NavigationHeaderPageObjects nav  = new NavigationHeaderPageObjects();
            CapsulesPageObjects         caps = new CapsulesPageObjects();
            LandingPageObjects          lan  = new LandingPageObjects();
            ChewablesPageObjects        cpo  = new ChewablesPageObjects();
            ChewablesOrderPageObjects   copo = new ChewablesOrderPageObjects();
            CartPageObjects             carp = new CartPageObjects();

            try
            {
                NavigationActions.NavigateOurProductsChewablesClick();

                try
                {
                    Assert.IsFalse(Driver.WebDriver.PageSource.Contains("£"));
//                    Assert.IsTrue(Driver.WebDriver.PageSource.Contains("€"));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);;
                }
                Thread.Sleep(1000);
                lan.CookieAlertAcceptButton.Click();
                Task.Delay(500).Wait(1500);
                cpo.ScrollViewport();
                cpo.ShopNowBerryChewables.Click();

                try
                {
                    Assert.IsTrue(Driver.WebDriver.PageSource.Contains("Berry Chewables"));
                }
                catch (Exception e)
                {
                    throw;
                }

                cpo.ScrollViewport();
                var NumOfProducts = copo.NumOfProductOrder.GetAttribute("value");

                try
                {
                    Assert.That(NumOfProducts, Is.EqualTo("1"));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);;
                }

                copo.IncrementArrowOrder.Click();
                var incrProductCount = copo.NumOfProductOrder.GetAttribute("value");
                Thread.Sleep(500);

                try
                {
                    Assert.That(incrProductCount, Is.EqualTo("2"));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);;
                }

                copo.DecrementArrowOrder.Click();
                var decrProductCount = copo.NumOfProductOrder.GetAttribute("value");

                try
                {
                    Assert.That(decrProductCount, Is.EqualTo("1"));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);;
                }

                copo.AddToCartOrder.Click();
                Thread.Sleep(1000);
                var NumInCart = nav.CartIconCounter.Text;
                Console.WriteLine(NumInCart);
                Thread.Sleep(500);

                try
                {
                    Assert.That(NumInCart, Is.EqualTo("1"));
                }
                catch (Exception e)
                {
                    throw;
                }

                nav.CartIconCounter.Click();
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e);
            }

            waitForElement.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(".m-icon-badge__counter")));
            nav.CheckoutButton.Click();
            carp.NavigateToProceedToCheckoutAndClick();
        }