Exemplo n.º 1
0
        public void RemoveProductFromContainer(ProductContainer container, InterctionControlSet controlSet, Product product)
        {
            switch (container)
            {
            case ProductContainer.Cart:
                switch (controlSet)
                {
                case InterctionControlSet.Product_Title:
                    throw new NotSupportedException();

                case InterctionControlSet.Product_Details:
                    throw new NotSupportedException();

                case InterctionControlSet.From_container:
                    m_home.OpenCart();
                    MidSleep();
                    var element = m_driver.FindElement(By.XPath("//div[@class='cart-item-container row']//button[text()='Remove']"));
                    TestHelper.JSexecutorClick(element, m_driver);
                    break;

                case InterctionControlSet.Container_Switch:
                    throw new NotSupportedException("Product need to be removed, not moved to other ontainer");

                default: break;
                }
                break;

            case ProductContainer.WishList:
                switch (controlSet)
                {
                case InterctionControlSet.Product_Title:
                    //product.categoryControl.Click();
                    var blackFridayControl = m_driver.FindElement(By.XPath("//div[@id='v-pills-tab']//button[text()=' Black Friday ']"));
                    TestHelper.JSexecutorClick(blackFridayControl, m_driver);
                    Thread.Sleep(2000);
                    var categoryControl = m_driver.FindElement(By.XPath("//div[@class='sub-menu opened']//div[@class='column ng-star-inserted']//li[1]/a"));
                    TestHelper.JSexecutorClick(categoryControl, m_driver);
                    MidSleep();
                    var element = m_driver.FindElement(By.XPath("//div[@class='description']//div[text()='" +
                                                                product.ProductName + "']/ancestor::div[@class='product-card-container']//button[text()='Remove from Wishlist']"));
                    TestHelper.JSexecutorClick(element, m_driver);
                    break;

                case InterctionControlSet.Product_Details:
                    //product.categoryControl.Click();
                    blackFridayControl = m_driver.FindElement(By.XPath("//div[@id='v-pills-tab']//button[text()=' Black Friday ']"));
                    TestHelper.JSexecutorClick(blackFridayControl, m_driver);
                    Thread.Sleep(2000);
                    categoryControl = m_driver.FindElement(By.XPath("//div[@class='sub-menu opened']//div[@class='column ng-star-inserted']//li[1]/a"));
                    TestHelper.JSexecutorClick(categoryControl, m_driver);
                    MidSleep();
                    element = m_driver.FindElement(By.XPath("//div[@class='row product-list']//div[@class='product-card-container']//div[@class='description']/div[text()='" + product.ProductName + "']"));
                    TestHelper.JSexecutorClick(element, m_driver);
                    SmallSleep();
                    element = m_driver.FindElement(By.XPath("//div[@class='wishlist-placeholder ng-star-inserted']//button/span[text()='Remove from wishlist']"));
                    TestHelper.JSexecutorClick(element, m_driver);
                    break;

                case InterctionControlSet.Container_Switch:
                    throw new NotSupportedException("Product need to be removed, not moved to other ontainer");

                case InterctionControlSet.From_container:
                    m_home.OpenWishlist();
                    MidSleep();
                    element = m_driver.FindElement(By.XPath("//div[@class='product-card-container']//div[@class='description']//div[text()='"
                                                            + product.ProductName + "']/ancestor::div[@class='product-card-container']//button[text()='Remove from Wishlist']"));
                    TestHelper.JSexecutorClick(element, m_driver);
                    break;

                default: break;
                }
                break;

            default: break;
            }
        }
Exemplo n.º 2
0
        public void AddProductToContainer(ProductContainer container, InterctionControlSet controlSet, Product product)
        {
            switch (container)
            {
            case ProductContainer.Cart:
                switch (controlSet)
                {
                case InterctionControlSet.Product_Title:
                    throw new NotSupportedException();

                case InterctionControlSet.From_container:
                    m_home.OpenCart();
                    MidSleep();
                    int count = CountProductsInContainer(ProductContainer.Cart, product);
                    if (count > 0)
                    {
                        m_driver.FindElement(By.XPath("//div[@class='cart-item ng-star-inserted']//span[@class='ng-arrow-wrapper'"));
                        SmallSleep();
                        TestHelper.JSexecutorClick(m_driver.FindElement(By.XPath("//*[@placeholder='Quantity']/ng-dropdown-panel//div[@role='option']/span[text()='" + (count++) + "']")), m_driver);
                        MidSleep();
                        break;
                    }
                    else
                    {
                        throw new NotSupportedException("Adding new product from cart is not supported");
                    }

                case InterctionControlSet.Product_Details:
                    var blackFridayControl = m_driver.FindElement(By.XPath("//div[@id='v-pills-tab']//button[text()=' Black Friday ']"));
                    blackFridayControl.Click();
                    Thread.Sleep(2000);
                    var categoryControl = m_driver.FindElement(By.XPath("//div[@class='sub-menu opened']//div[@class='column ng-star-inserted']//li[1]/a"));
                    //TestHelper.JSexecutorClick(categoryControl, m_driver);
                    TestHelper.JSexecutorClick(categoryControl, m_driver);
                    MidSleep();
                    var element = m_driver.FindElement(By.XPath("//div[@class='product-card-container']//div[@class='description']//div[text()='" +
                                                                product.ProductName + "']//parent::div"));
                    TestHelper.JSexecutorClick(element, m_driver);
                    SmallSleep();
                    element = m_driver.FindElement(By.XPath("//button[text()='add to cart']"));
                    TestHelper.JSexecutorClick(element, m_driver);
                    SmallSleep();
                    element = m_driver.FindElement(By.XPath("//div[@class='modal-content']//button[text()=' view cart ']"));
                    TestHelper.JSexecutorClick(element, m_driver);
                    break;

                case InterctionControlSet.Container_Switch:
                    m_home.OpenWishlist();
                    MidSleep();
                    element = m_driver.FindElement(By.XPath("//div[@class='description']//div[text()='" +
                                                            product.ProductName + "']/ancestor::div[@class='product-card-container']//button/span[text()='Add to cart']"));
                    TestHelper.JSexecutorClick(element, m_driver);
                    MidSleep();
                    break;

                default: break;
                }
                break;

            case ProductContainer.WishList:
                SmallSleep();
                switch (controlSet)
                {
                case InterctionControlSet.Product_Title:
                    //TestHelper.JSexecutorClick(product.categoryControl, m_driver);
                    var blackFridayControl = m_driver.FindElement(By.XPath("//div[@id='v-pills-tab']//button[text()=' Black Friday ']"));
                    TestHelper.JSexecutorClick(blackFridayControl, m_driver);
                    Thread.Sleep(2000);
                    var categoryControl = m_driver.FindElement(By.XPath("//div[@class='sub-menu opened']//div[@class='column ng-star-inserted']//li[1]/a"));
                    TestHelper.JSexecutorClick(categoryControl, m_driver);
                    MidSleep();
                    TestHelper.JSexecutorClick(m_driver.FindElement(By.XPath("//div[@class='description']//div[text()='" +
                                                                             product.ProductName + "']/ancestor::div[@class='product-card-container']//button[text()='Add to Wishlist']")), m_driver);
                    break;

                case InterctionControlSet.From_container:
                    throw new NotSupportedException("Adding product from wishlist to wishlist is not supported");

                case InterctionControlSet.Product_Details:
                    //product.categoryControl.Click();
                    blackFridayControl = m_driver.FindElement(By.XPath("//div[@id='v-pills-tab']//button[text()=' Black Friday ']"));
                    TestHelper.JSexecutorClick(blackFridayControl, m_driver);
                    Thread.Sleep(2000);
                    categoryControl = m_driver.FindElement(By.XPath("//div[@class='sub-menu opened']//div[@class='column ng-star-inserted']//li[1]/a"));
                    TestHelper.JSexecutorClick(categoryControl, m_driver);
                    MidSleep();
                    var element = m_driver.FindElement(By.XPath("//div[@class='row product-list']//div[@class='product-card-container']//div[@class='description']/div[text()='" +
                                                                product.ProductName + "']"));
                    TestHelper.JSexecutorClick(element, m_driver);
                    SmallSleep();
                    element = m_driver.FindElement(By.XPath("//div[@class='wishlist-placeholder ng-star-inserted']//button/span[text()='Add to wishlist']"));
                    TestHelper.JSexecutorClick(element, m_driver);
                    break;

                case InterctionControlSet.Container_Switch:
                    m_home.OpenCart();
                    MidSleep();
                    element = m_driver.FindElement(By.XPath("//div[@class='cart-item ng-star-inserted']//button[text()='Move to wishlist']"));
                    TestHelper.JSexecutorClick(element, m_driver);
                    SmallSleep();
                    break;

                default: break;
                }
                break;

            default: break;
            }
        }