protected IWebElement FindByCssWithText(string css, string text)
        {
            var locator = ExpectedConditions.TextToBePresentInElementLocated(By.CssSelector(css), text);

            new WebDriverWait(driver, TimeSpan.FromSeconds(3)).Until(locator);
            return(driver.FindElement(By.CssSelector(css)));
        }
Beispiel #2
0
        public void RemoveProductFromCart()
        {
            driver.Url = "http://localhost/litecart/en/";
            //add products
            for (int i = 1; i <= 3; i++)
            {
                driver.FindElement(By.CssSelector("div#box-most-popular li:nth-of-type(1)")).Click();
                //size dropdown for yellow duck
                if (IsElementPresent(driver, By.CssSelector("td.options>select")))
                {
                    driver.FindElement(By.CssSelector("select > option[value='Small']")).Click();
                }
                driver.FindElement(By.CssSelector("[name='add_cart_product']")).Click();
                // wait until cart counter is refreshed
                string number = i + "";
                wait.Until(ExpectedConditions.TextToBePresentInElementLocated(By.CssSelector("div#cart span.quantity"), number));
                // go to main page
                driver.Url = "http://localhost/litecart/en/";
            }
            driver.FindElement(By.LinkText("Checkout »")).Click();
            // deletion items from the cart
            var counter = driver.FindElements(By.CssSelector("div#order_confirmation-wrapper td.item")).Count;

            for (int i = 0; i < counter; i++)
            {
                var    name         = driver.FindElement(By.CssSelector("[name = 'cart_form'] a > strong")).Text;             //product title
                string elementXpath = string.Format("//div[@id='order_confirmation-wrapper']//td[contains(., '{0}')]", name); // product in table
                var    element      = driver.FindElement(By.XPath(elementXpath));
                driver.FindElement(By.CssSelector("[name='remove_cart_item']")).Click();
                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
                wait.Until(ExpectedConditions.StalenessOf(element));
            }
        }
 protected void _waitForTextInElement(RemoteWebDriver driver, By by, string text)
 {
     _getWebDriverWait(driver)
     .Until(
         ExpectedConditions.TextToBePresentInElementLocated(by, text)
         );
 }
        public void VerifyCart()
        {
            var Shop = GoToShopPage(driver);

            //add products to cart
            for (var i = 1; i <= 3; i++)
            {
                var detailPage = Shop.SelectProduct("Most Popular", 1);
                if (detailPage.IsSizeControlExist())
                {
                    detailPage.SelectSize("Small");
                }
                detailPage.AddToCart();
                wait.Until(ExpectedConditions.TextToBePresentInElement(detailPage.QuantityElement, i.ToString()));
                Shop = GoToShopPage(driver);
            }

            var Cart         = Shop.GoToCart();
            int ProductCount = Cart.GetProductsCount();

            if (ProductCount > 1)
            {
                Cart.SelectFirstShortcut();
            }                               //stop crazy carusel
            while (Cart.IsAnyProductExist())
            {
                Cart.DeleteFirstProduct();
                ProductCount--;
            }
            wait.Until(ExpectedConditions.TextToBePresentInElementLocated(By.CssSelector("em"), "There are no items in your cart."));
            Assert.IsTrue(Cart.AreElementsPresent(By.XPath("//em[.='There are no items in your cart.']")));
        }
Beispiel #5
0
        public String SearchForDomain(String sDomainTosaerch, byte iPages)
        {
            String sOut = "";

            {
                Int32 iPage = Convert.ToByte(CurrentPage.Text);
                do
                {
                    List <FoundElement> lOut = new List <FoundElement>();
                    ReadOnlyCollection <IWebElement> lFoundResults = _driver.FindElements(By.XPath(xPathToSearchResultUrl));
                    foreach (IWebElement Res in lFoundResults)
                    {
                        String sCurrent = Res.Text;
                        if (sCurrent.Contains(sDomainTosaerch))
                        {
                            sOut = sCurrent;
                            Console.WriteLine("Founded at page " + iPage);
                            break;
                        }
                    }
                    if ((iPage < iPages) && sOut == "")//AM 04/20/2017 fixed logic error
                    {
                        NextPage.Click();
                        WebDriverWait wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(ExplicitlyWait));
                        wait.Until(ExpectedConditions.TextToBePresentInElementLocated(By.XPath(xPathCurrentPage), (iPage + 1).ToString()));
                    }
                } while ((++iPage <= iPages) && sOut == "");
            }

            return(sOut);
        }
Beispiel #6
0
        public void ProductCart()
        {
            // повторим 3 раза, чтобы в корзине было 3 товара
            for (int i = 0; i < 3; i++)
            {
                // открыть главную страницу
                driver.Url = "http://localhost/litecart";

                // открыть первый товар из списка
                driver.FindElement(By.CssSelector(".product")).Click();
                int cartCountBefore = int.Parse(driver.FindElement(By.CssSelector(".quantity")).GetAttribute("textContent"));

                // добавить его в корзину(при этом может случайно добавиться товар, который там уже есть, ничего страшного)
                driver.FindElement(By.Name("add_cart_product")).Click();

                // подождать, пока счётчик товаров в корзине обновится
                string        cartCountAfter = (cartCountBefore + 1).ToString();
                WebDriverWait wait           = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
                wait.Until(ExpectedConditions.TextToBePresentInElementLocated(By.CssSelector(".quantity"), cartCountAfter));
            }

            // открыть корзину(в правом верхнем углу кликнуть по ссылке Checkout)
            driver.FindElement(By.LinkText("Checkout »")).Click();

            // удалить все товары из корзины один за другим, после каждого удаления подождать, пока внизу обновится таблица
            for (int i = 0; i < 3; i++)
            {
                driver.FindElement(By.Name("remove_cart_item")).Click();
                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
                wait.Until(ExpectedConditions.ElementToBeClickable(By.Name("remove_cart_item")));
            }
        }
Beispiel #7
0
        public void Test()
        {
            driver.Url = "http://localhost/litecart/";

            for (int i = 0; i < 3; i++)
            {
                driver.FindElement(By.CssSelector("li.product")).Click();
                if (driver.FindElements(By.CssSelector("select[name='options[Size]']")).Count() > 0)
                {
                    SelectElement selectElement = new SelectElement(driver.FindElement(By.CssSelector("select[name='options[Size]']")));
                    selectElement.SelectByIndex(1);
                }
                driver.FindElement(By.CssSelector("button[name=add_cart_product]")).Click();
                wait.Until(ExpectedConditions.TextToBePresentInElementLocated(By.CssSelector("div#cart span.quantity"), (i + 1).ToString()));
                driver.Navigate().Back();
            }

            driver.FindElement(By.CssSelector("div#cart a.link")).Click();

            while (driver.FindElements(By.CssSelector("div#box-checkout-summary table tr td")).Count > 0)
            {
                driver.FindElement(By.CssSelector("button[name = remove_cart_item]")).Click();
                wait.Until(ExpectedConditions.StalenessOf(driver.FindElement(By.CssSelector("div#box-checkout-summary table tr td"))));
            }
        }
Beispiel #8
0
        protected IWebElement WaitUntilElementHasText(By locator, string text, int timeoutSeconds = DefaultWaitSeconds)
        {
            var wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(timeoutSeconds));

            wait.Message = "Element " + locator + " did not become clickable before timeout.";
            wait.Until(ExpectedConditions.TextToBePresentInElementLocated(locator, text));
            return(FindElement(locator));
        }
        public void OpenPageInNewTab(string link, string textToWait)
        {
            driver.ExecuteJavaScript("window.open();");
            var newTabInstance = driver.WindowHandles[driver.WindowHandles.Count - 1];

            driver.SwitchTo().Window(newTabInstance);
            driver.Url = link;
            wait.Until(ExpectedConditions.TextToBePresentInElementLocated(By.CssSelector("#content>h1"), textToWait));
        }
Beispiel #10
0
        public static void CheckMailBoxCreated(string login)
        {
            WebDriverWait wait = new WebDriverWait(browser, TimeSpan.FromSeconds(30));

            wait.Until(ExpectedConditions.TextToBePresentInElementLocated(By.XPath(UserNameClass), login));

            Thread.Sleep(3000);
            Console.WriteLine(String.Format("The user with login {0} is successfully created!", login));
            CloseOrangeMailboxPage();
        }
        public ContactPage selectState(string state)
        {
            SelectElement selector = new SelectElement(State);

            selector.SelectByText(state);
            var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            var e    = wait.Until(ExpectedConditions.TextToBePresentInElementLocated(By.Id("County"), "--Select"));

            return(this);
        }
Beispiel #12
0
        public void AddItemToBasket(int currentstep, int number_of_items_in_the_basket)
        {
            driver.FindElement(By.CssSelector("button[name=add_cart_product]")).Click();
            string CourtNumber = (currentstep + 1).ToString();

            wait.Until(ExpectedConditions.TextToBePresentInElementLocated(By.CssSelector("span.quantity"), CourtNumber));
            int ItemsInTheBasketNew = Int32.Parse(driver.FindElement(By.CssSelector("span.quantity")).GetAttribute("innerText"));

            NUnit.Framework.Assert.AreEqual(number_of_items_in_the_basket, ItemsInTheBasketNew - 1);
        }
        public void VerifyEveryDugHasSticker()
        {
            driver.Url = "http://localhost/litecart/en/";
            wait.Until(ExpectedConditions.TextToBePresentInElementLocated(By.CssSelector("#box-most-popular"), "Most Popular"));


            var element  = driver.FindElement(By.CssSelector("[name=login]"));
            var size     = element.Size;
            var location = element.Location;
        }
Beispiel #14
0
        public void DownloadSourceCode(string email, string name)
        {
            Email.SendKeys(email);
            Name.SendKeys(name);
            DownloadButton.Click();
            var successMessage = string.Format("Thank you for downloading {0}! An email was sent to {1}. Check your inbox.", name, email);
            var waitElem       = new WebDriverWait(_driver, TimeSpan.FromSeconds(30));

            waitElem.Until(ExpectedConditions.TextToBePresentInElementLocated(By.Id("successMessageId"), successMessage));
        }
Beispiel #15
0
        /// <summary>
        /// Assigns a Grade Set to a unique subject with single column
        /// </summary>
        public GradesetSearchPanel ClickAssignGradeSet(string SubjectName)
        {
            AddSubjects addsubject = new AddSubjects();
            //Getting the Subject ID
            List <Guid> SubjectID = new List <Guid>();

            SubjectID = TestData.CreateGuidList("Select ID From AssessmentSubject Where Name like '%" + SubjectName + "%'", "ID");
            WebContext.WebDriver.FindElement(By.CssSelector("button[data-ajax-url*='" + SubjectID[0] + "']")).Click();
            waiter.Until(ExpectedConditions.TextToBePresentInElementLocated(By.CssSelector("h4[data-automation-id='select_gradeset_popup_header_title']"), "Select Gradeset"));
            return(new GradesetSearchPanel());
        }
Beispiel #16
0
 public virtual void AguardarVerTexto(By seletor, String texto, TimeSpan tempo)
 {
     try
     {
         new WebDriverWait(Driver, tempo)
         .Until(ExpectedConditions.TextToBePresentInElementLocated(seletor, texto));
     }
     catch (Exception e)
     {
         new Exception("O texto não foi apresentado na tela. Motivo: " + e.Message);
     }
 }
        public static bool IsTextPresentInElementLocated(this IWebDriver driver, By by, string text)
        {
            var wait = new WebDriverWait(driver, ImplicitWait);

            try
            {
                return(wait.Until(ExpectedConditions.TextToBePresentInElementLocated(by, text)));
            }
            catch (WebDriverTimeoutException)
            {
                return(false);
            }
        }
Beispiel #18
0
        internal void RemoveAllProductsFromCart()
        {
            var count = driver.FindElements(By.Name("remove_cart_item")).Count;

            while (count > 0)
            {
                driver.FindElement(By.Name("remove_cart_item"), 5000).Click();
                wait.Until(ExpectedConditions.StalenessOf(driver.FindElement(By.ClassName("loader"), 2000)));
                count--;
            }

            wait.Until(ExpectedConditions.TextToBePresentInElementLocated(By.CssSelector("#box-checkout p"), "There are no items in your cart."));
        }
Beispiel #19
0
        public void LoginForm_PasswordRestoreWithValidEmail()
        {
            using (IWebDriver driver = new FirefoxDriver())
            {
                driver.Navigate().GoToUrl(gg);

                //Открытие формы
                IWebElement formLink = driver.FindElement(By.XPath(@"//*[@id=""top_back""]/div[3]/a[1]"));
                formLink.Click();

                WebDriverWait wait        = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
                IWebElement   overlay     = driver.FindElement(By.Id("cboxOverlay"));
                IWebElement   colorbox    = driver.FindElement(By.Id("colorbox"));
                IWebElement   messageBox  = driver.FindElement(By.ClassName("status-error"));
                IWebElement   emailField  = wait.Until(ExpectedConditions.ElementToBeClickable(By.Name("Email")));
                IWebElement   restoreLink = wait.Until(ExpectedConditions.ElementToBeClickable(By.LinkText("Я не помню пароль")));

                Assert.IsTrue(colorbox.Displayed, "Форма не открылась");

                emailField.SendKeys(validEmail);
                restoreLink.Click();
                try { wait.Until(ExpectedConditions.TextToBePresentInElementLocated(By.ClassName("status-message"), "Инструкция по восстановлению отправлена")); }
                catch (Exception e) { Assert.Fail("Не появилось сообщение об отправке письма"); }
            }
            using (Pop3Client client = new Pop3Client())
            {
                client.Connect(hostname, port, useSsl);
                client.Authenticate(validEmail, emailPass);

                int messageNumber = client.GetMessageCount();
                int i             = 0;
                while (messageNumber == 0 && i < 60)
                {
                    client.Disconnect();
                    System.Threading.Thread.Sleep(5000);
                    client.Connect(hostname, port, useSsl);
                    client.Authenticate(validEmail, emailPass);
                    messageNumber = client.GetMessageCount();
                    i             = i++;
                }

                Assert.IsTrue(messageNumber > 0, "Письмо не пришло");

                MessageHeader  headers = client.GetMessageHeaders(messageNumber);
                RfcMailAddress from    = headers.From;
                string         subject = headers.Subject;
                client.DeleteAllMessages();

                Assert.IsFalse(from.HasValidMailAddress && from.Address.Equals("*****@*****.**") && "Восстановление пароля на Gama - Gama".Equals(subject), "Письмо не пришло");
            }
        }
Beispiel #20
0
        public void RemoveAllOrders()
        {
            var initialOrdersCount = Orders.Count;

            for (var i = 0; i < initialOrdersCount; i++)
            {
                var ordersTable = Driver.FindElement(By.XPath("//table[@class='dataTable rounded-corners']"));
                Wait.Until(ExpectedConditions.ElementToBeClickable(RemoveButton));
                RemoveButton.Click();
                Wait.Until(ExpectedConditions.StalenessOf(ordersTable));
            }

            Wait.Until(ExpectedConditions.TextToBePresentInElementLocated(By.XPath("//em"), "There are no items in your cart."));
        }
Beispiel #21
0
        public void test()
        {
            driver.Url = "http://localhost/litecart/en/";
            wait.Until(ExpectedConditions.TextToBePresentInElementLocated(By.CssSelector("#box-most-popular"), "Most Popular"));
            var element = driver.FindElement(By.CssSelector("[placeholder=Search]"));

            element.Clear();
            element.SendKeys("test           test" + Keys.Enter);
            //var a = driver.FindElement(By.CssSelector("title")).Text; //вообще ничего не возвращает.
            //т.е ТО, ЧТО ВЫГЛЯДИТ КАК ТЕКСТ У ЭЛЕМЕНТА НЕ ФАКТ, ЧТО БУДЕТ ВОЗВРАЩАТЬСЯ С ПОМОЩЬЮ МЕТОДА getText(в C# свойства Text)
            wait.Until(x => x.FindElement(By.CssSelector("title")).GetAttribute("textContent").Contains("test"));
            var elementTitle = driver.FindElement(By.CssSelector("title"));

            elementTitle.GetAttribute("textContent");
        }
Beispiel #22
0
        public void VerifyEveryDugHasSticker()
        {
            driver.Url = "http://localhost/litecart/en/";
            wait.Until(ExpectedConditions.TextToBePresentInElementLocated(By.CssSelector("#box-most-popular"), "Most Popular"));


            var attribute = driver.FindElement(By.CssSelector("[name=login]")).GetAttribute("textContent");
            var field     = driver.ExecuteJavaScript <IWebElement>("return document.querySelector('[name=login')");
            //var property = field.GetProperty("type");

            //Берем исходный код DOM всех страницы используя GetAttribute("outerHTML") у элемента body
            var bodyAttribute = driver.FindElement(By.CssSelector("body")).GetAttribute("outerHTML");

            //GetAttribute
            //1.value - содержимое полей ввода. Ввел что-то в поле ввода.
            //аттрибут value пустой, а вот PROPERTY value имеет значение того текста, который я ввел.
            //т.е аттрибут и property разные! Метод  GetAttribute вернет значение property. Значение ТЕКСТА поля ввода будет ""
            var element = driver.FindElement(By.CssSelector("[placeholder=Search]"));

            element.Clear();
            element.SendKeys("test");
            var valueTextBox = element.GetAttribute("value");

            element.Clear();
            element.SendKeys("test2");
            valueTextBox = element.GetAttribute("value");

            //2. href , src. Аттрибуты и Property могут отличаться. Атрибут имеет значение /litecart/  - это относительная ссылка т.к в ней
            //не указан адрес сервера. А Property имеет значение "http://localhost/litecart/".
            var linkElement  = driver.FindElement(By.CssSelector("#breadcrumbs-wrapper a"));
            var hrefProperty = linkElement.GetAttribute("href"); //имеет значение "http://localhost/litecart/".

            //3. Булевские аттрибуты :selected, readonly, checked etc. Для этих аттрибутов селениум возвращает всегда
            //одно значение : true - если этот аттрибут присутствует и null если он отсутсвует. Когда аттрибут присутствует, то
            // у него может быть значение. Это значение полностью игнорируется. Если он есть, то всегда возвращается значение true.
            //откроем поп ап
            driver.FindElement(By.CssSelector(".fancybox-region")).Click();
            wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("#fancybox-content")));
            var selectedElement    = driver.FindElement(By.CssSelector("[name=currency_code] [value=USD]"));
            var notSelectedElement = driver.FindElement(By.CssSelector("[name=currency_code] [value=EUR]"));

            var selectedValue  = selectedElement.GetAttribute("selected");      //вернуло значение true
            var selectedValue1 = selectedElement.Selected;                      //вернуло значение true

            var notSelectedValue = notSelectedElement.GetAttribute("selected"); //вернуло null т.к этот элемент не выбран.
            //хотя и свойство selected этого элемента имеет значение false, но Selenium вернул null т.к он возвращает или true или null.
            var selectedValue2 = notSelectedElement.Selected;                   //свойство Selected вернуло false , а не null
        }
Beispiel #23
0
        /**
         * Checks for the specified text within the web element found using the provided locator Allows for specifying the
         * timeout delay in seconds.
         *
         * @param locator
         * @param value
         * @param timeout
         * @return boolean
         */
        public bool isTextPresent(By locator, String value, int timeout)
        {
            WebDriverWait wait   = new WebDriverWait(webDriver, TimeSpan.FromSeconds(timeout));
            bool          result = false;

            try
            {
                result = wait.Until(ExpectedConditions.TextToBePresentInElementLocated(locator, value));
            }
            catch (TimeoutException toe)
            {
                result = false;
            }

            return(result);
        }
        /// <summary>
        /// Checks for specified text within the web element specified by locator and returns true if it exists
        /// </summary>
        /// <param name="locator"></param>
        /// <param name="value"></param>
        public bool isTextPresent(By locator, string value)
        {
            bool result = false;

            try
            {
                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(Timeout));
                result = wait.Until(ExpectedConditions.TextToBePresentInElementLocated(locator, value));
            }
            catch (TimeoutException)
            {
                Browser.CaptureError(driver, "timeout" + new DateTime().ToString("yyyyMMddhhmm") + ".jpg");
                result = false;
            }
            return(result);
        }
        public void test()
        {
            driver.Url = "https://selenium2.ru/";
            var element = driver.FindElement(By.CssSelector("[itemprop=headline] a"));
            var text    = element.Text;

            wait.Until(ExpectedConditions.TextToBePresentInElementLocated(By.CssSelector("[itemprop=headline] a"), "Что такое"));

            //Сhrome и Firefox показуют немного разные данные.
            var color           = element.GetCssValue("color");
            var backGroundColor = element.GetCssValue("background-color");
            var borderColor     = element.GetCssValue("border-color");
            //комбинированные свойства (font, background)-> Драйвер IE вообще не возвращает комбинированные свойства.
            //Нужно указывать каждое свойство по отдельности.

            //ИТОГ: нужно проверить, что нужным элементам назначены правильные классы, а цвета, шрифты и т.д - лучше провкрять вручную.
        }
        //waits for an element to be visible and have the exact given text for the given amount of time
        protected IWebElement WaitForElementToHaveText(By by, string text, int seconds)
        {
            string logMsg = "WaitForElementToHaveText " + by.ToString() + " : '" + text + "' for " + seconds + " seconds top.";

            TestsLogger.Log(logMsg);
            try {
                IWebElement   we            = WaitForElementToBeVisible(by, seconds);
                WebDriverWait webDriverWait = new WebDriverWait(this.driver, GetTimeSpanInMilliseconds(seconds));
                webDriverWait.IgnoreExceptionTypes(typeof(NoSuchElementException)); //to avoid instant failure breaks
                webDriverWait.Until(ExpectedConditions.TextToBePresentInElementLocated(by, text));
                return(we);
            }
            catch (WebDriverException exception)
            {
                throw new MissingElementException("Exception when performing: " + logMsg, exception);
            }
        }
        private static void AssertPageLink(IWebDriver driver, string pageAnchorId, string expectedTitle, string textContainerId, string expectedText)
        {
            DialogHelper.TestDialog(driver, pageAnchorId, SiteConstants.ExternalModalId, () =>
            {
                driver.WaitUntil(ExpectedConditions.TextToBePresentInElementLocated(By.Id(SiteConstants.ExternalPageTitleHeaderId), expectedTitle),
                                 Invariant($"Could not verify external page title: {expectedTitle}"));

                driver.SwitchTo().Frame(driver.FindElement(By.Id(SiteConstants.ExternalPageFrameId)));
                driver.WaitUntil(ExpectedConditions.TextToBePresentInElementLocated(By.Id(textContainerId), expectedText),
                                 Invariant($"Could not verify external page text '{expectedText}'"));
                driver.SwitchTo().DefaultContent();

                Console.WriteLine("Dismissing external page modal dialog...");
                //we can't click the close button directly because it's covered in a bootstrap overlay
                //clicking the overlay isn't straightforward either (it fails due to the iframe)
                //The easiest way to dismiss the dialog is to emulate an ESC key press
                driver.FindElement(By.Id(SiteConstants.ExternalModalId)).SendKeys(Keys.Escape);
            });
        }
Beispiel #28
0
        public void AddProductToCart(int productTotalNumber)
        {
            for (int stepNumber = 1; stepNumber <= productTotalNumber; stepNumber++)
            {
                driver.FindElement(By.CssSelector("div#box-most-popular li:first-child")).Click();
                wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("h1.title")));

                if (IsElementPresent(By.CssSelector("select[name='options[Size]']")))
                {
                    SelectElement select = new SelectElement(driver.FindElement(By.CssSelector("select[name='options[Size]']")));
                    select.SelectByIndex(1);
                }

                driver.FindElement(By.CssSelector("button[value='Add To Cart']")).Click();
                wait.Until(ExpectedConditions
                           .TextToBePresentInElementLocated(By.CssSelector("div#cart span.quantity"), stepNumber.ToString()));
                NavigateBackToMainPage();
            }
        }
        public void Task13()
        {
            chrome = new ChromeDriver();
            wait   = new WebDriverWait(chrome, TimeSpan.FromSeconds(15));
            for (var i = 0; i < 3; i++)
            {
                chrome.Navigate().GoToUrl(shopAddress);

                chrome.FindElement(By.XPath("(//*[@id='box-latest-products']//li[contains(@class,'product')])[1]"))
                .Click();
                var quantityOld = chrome.FindElement(By.XPath("//*[@id='cart']//*[@class='quantity']")).Text;
                new SelectElement(chrome.FindElement(By.Name("options[Size]"))).SelectByIndex(1);

                chrome.FindElement(By.Name("add_cart_product")).Click();
                wait.Until(chrome => !chrome.FindElement(By.XPath("//*[@id='cart']//*[@class='quantity']")).Text
                           .Equals(quantityOld));
            }

            chrome.FindElement(By.XPath("//*[@id='cart']//a[@class='link']")).Click();
            for (var i = 3; i > 1; i--)
            {
                var productCount = chrome.FindElement(By.XPath($"//*[@id='order_confirmation-wrapper']//tr[2]/td[1]"));

                chrome.FindElement(By.Name("quantity")).Clear();
                chrome.FindElement(By.Name("quantity")).SendKeys($"{i - 1}");
                chrome.FindElement(By.Name("update_cart_item")).Click();
                wait.Until(chrome => ExpectedConditions.StalenessOf(productCount));
            }

            wait.Until(ExpectedConditions.TextToBePresentInElementLocated(
                           By.XPath($"//*[@id='order_confirmation-wrapper']//tr[2]/td[1]"), "1"));
            var updateButtonElement =
                chrome.FindElement(By.Name("update_cart_item"));

            chrome.FindElement(By.Name("quantity")).Clear();
            chrome.FindElement(By.Name("quantity")).SendKeys("0");
            chrome.FindElement(By.Name("update_cart_item")).Click();
            wait.Until(chrome => ExpectedConditions.StalenessOf(updateButtonElement));
            wait.Until(chrome =>
                       ExpectedConditions.VisibilityOfAllElementsLocatedBy(
                           By.XPath("//*[@id='checkout-cart-wrapper']//*[.='There are no items in your cart.']")));
        }
        //Searches Marksheet by its Name
        public string SearchByName(string MarksheetNameText, bool MarksheetActive, bool takeScreenPrint)
        {
            WebDriverWait waiter = new WebDriverWait(WebContext.WebDriver, TimeSpan.FromSeconds(MarksheetConstants.Timeout));

            waiter.Until(ExpectedConditions.ElementToBeClickable(MarksheetConstants.SearchMarksheetPanelButton));
            WebContext.WebDriver.FindElement(MarksheetConstants.SearchMarksheetPanelButton).Click();
            waiter.Until(ExpectedConditions.ElementIsVisible(MarksheetConstants.SearchMarksheetName));
            WebContext.WebDriver.FindElement(MarksheetConstants.SearchMarksheetName).SendKeys(MarksheetNameText);
            waiter.Until(ExpectedConditions.ElementToBeClickable(MarksheetConstants.ShowMoreLink));
            WebContext.WebDriver.FindElement(MarksheetConstants.ShowMoreLink).Click();
            waiter.Until(ExpectedConditions.ElementToBeClickable(MarksheetConstants.SearchButton));
            if (MarksheetActive == false)
            {
                waiter.Until(ExpectedConditions.ElementToBeSelected(MarksheetConstants.ActiveCheckBox));
                WebContext.WebDriver.FindElement(MarksheetConstants.ActiveCheckBox).Click();
            }

            WebContext.WebDriver.FindElement(MarksheetConstants.SearchButton).Click();
            waiter.Until(ExpectedConditions.TextToBePresentInElementLocated(MarksheetConstants.SearchResultText, MarksheetNameText));
            ReadOnlyCollection <IWebElement> SearchResult = WebContext.WebDriver.FindElements(MarksheetConstants.SearchResultText);

            var ResultText = "";

            try
            {
                foreach (IWebElement eachresult in SearchResult)
                {
                    if (eachresult.Text == MarksheetNameText)
                    {
                        waiter.Until(ExpectedConditions.ElementToBeClickable(eachresult));
                        ResultText = eachresult.Text;
                    }
                }
            }
            catch
            {
                Console.WriteLine("No Marksheet Found with Name : {0}", MarksheetNameText);
            }

            return(ResultText);
        }