Beispiel #1
0
        public ManufacturerPage OpenRandomManufacturerPage(PageBase currentPage)
        {
            // Open brand menu
            var menuItems = currentPage.Menu.OpenMenu("Бренды");

            _wait.Until(ExpectedConditions.ElementIsVisible(
                            By.CssSelector("li.megamenu-parent-block a.megamenu-parent-img img[title=\"Swiss Military\"]")));

            // Click on Swiss Military image
            randomSelector.Select(menuItems).Title.Click();

            return(ManufacturerPage.WaitForPage(_driver));
        }
Beispiel #2
0
        public ProductPage OpenRandomProductPage(ManufacturerPage manufacturerPage)
        {
            if (!manufacturerPage.HasProducts)
            {
                throw new Exception("There is no products on manufacturer page");
            }

            var productCards = manufacturerPage.GetProductCards();

            randomSelector.Select(productCards).Title.Click();

            return(ProductPage.WaitForPage(_driver));
        }
Beispiel #3
0
        public void ShouldBeAbleToBuyRandomProduct()
        {
            // Open brand menu
            PageBase currentPage = new HomePage(_driver);

            ManufacturerPage manufacturerPage = null;
            ProductPage      productPage      = null;

            for (int i = 0; i < 50; i++)
            {
                currentPage = manufacturerPage = OpenRandomManufacturerPage(currentPage);

                if (!manufacturerPage.HasProducts)
                {
                    manufacturerPage = null;
                    continue;
                }

                productPage = OpenRandomProductPage(manufacturerPage);

                if (!productPage.CanAddProductToCart)
                {
                    productPage = null;
                    continue;
                }

                break;
            }

            if (manufacturerPage == null || productPage == null)
            {
                throw new Exception("Could not find available manufacturer and product");
            }

            var orderPage = OrderProductOnProductPage(productPage);

            Assert.AreEqual("Оформление заказа", orderPage.Title);
            Assert.AreEqual("Оформление заказа", orderPage.Header.GetInnerHtml());

            PopulateOrderForm(orderPage);

            if (!SystemRuntime.IsDebug())
            {
                ExcuteOrderOnOrderPage(orderPage);
            }
        }
Beispiel #4
0
        public ManufacturerPage OpenManufacturerPage(string manufacturer)
        {
            var menuItems = _currentPage.Menu.OpenMenu("Бренды");

            _wait.Until(ExpectedConditions.ElementIsVisible(
                            By.CssSelector($"li.megamenu-parent-block a.megamenu-parent-img img[title=\"{manufacturer}\"]")));

            var menuItem = menuItems.FirstOrDefault(item => item.Image.GetAttribute("title") == manufacturer);

            if (menuItem == null)
            {
                throw new Exception($"Could not find item for manufacturer '{manufacturer}' in brands menu");
            }

            menuItem.Image.Click();

            return((ManufacturerPage)(_currentPage = ManufacturerPage.WaitForPage(_driver)));
        }