/// <summary>
 /// Wait for element nor element text not present for given timeout
 /// </summary>
 /// <param name="by"></param>
 /// <param name="textPresent"></param>
 /// <param name="timeOutSeconds"></param>
 public static void WaitForElementTextNotPresent(By by, string textPresent, TimeSpan timeOutSecs)
 {
     try
     {
         WebDriverWait wait = new WebDriverWait(DriverInstance.Instance, timeOutSecs);
         wait.Until(ExpectedConditions.InvisibilityOfElementWithText(by, textPresent));
         LoggerInstance.log.Info("Driver explicitly waits " + timeOutSecs + " seconds for " + textPresent + " to be disappear");
     }
     catch (NoSuchElementException elementNotPresent)
     {
         LoggerInstance.log.Error(elementNotPresent.Message, elementNotPresent);
     }
     catch (WebDriverTimeoutException webdriverTimeOut)
     {
         LoggerInstance.log.Error(webdriverTimeOut.Message, webdriverTimeOut);
     }
     catch (TimeoutException timeOutEx)
     {
         LoggerInstance.log.Error(timeOutEx.Message, timeOutEx);
     }
     catch (Exception e)
     {
         LoggerInstance.log.Error(e.Message, e);
     }
 }
        public void WaitUntilTextIsInvisible(By locatorStrategy, string text, int timeoutInSeconds = 120)
        {
            DefaultWait <IWebDriver> fluentWait = new DefaultWait <IWebDriver>(_driver);

            fluentWait.Timeout         = TimeSpan.FromSeconds(120);
            fluentWait.PollingInterval = TimeSpan.FromMilliseconds(250);
            fluentWait.IgnoreExceptionTypes(typeof(NoSuchElementException));

            IWebElement searchResult = null;
            bool        staleElement = true;

            while (staleElement)
            {
                try
                {
                    fluentWait.Until(ExpectedConditions.InvisibilityOfElementWithText(locatorStrategy, text));
                    staleElement = false;
                }
                catch (StaleElementReferenceException e)
                {
                    staleElement = true;
                }
                catch (NoSuchElementException)
                {
                    staleElement = true;
                }
                catch (Exception)
                {
                    staleElement = true;
                }
            }
        }
Example #3
0
        public void RecycleBin()
        {
            driver.Navigate().GoToUrl(baseURL);

            for (int i = 1; i <= 3; i++)
            {
                driver.FindElement(By.CssSelector("ul.listing-wrapper li.product")).Click();                                        //открыть первый товар

                var counterInCart = driver.FindElement(By.CssSelector("#cart span.quantity")).Text;                                 // количество в корзине

                driver.FindElement(By.Name("add_cart_product")).Click();                                                            //добавить товар в корзину

                wait.Until(ExpectedConditions.InvisibilityOfElementWithText(By.CssSelector("#cart span.quantity"), counterInCart)); // проверяем что количество в корзине изменилось

                driver.FindElement(By.Id("logotype-wrapper")).Click();                                                              // домашняя страница
            }

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

            while (driver.FindElements(By.Name("remove_cart_item")).Count > 0)
            {
                var removeButton = driver.FindElement(By.Name("remove_cart_item"));

                removeButton.Click();

                wait.Until(ExpectedConditions.StalenessOf(removeButton));
            }

            driver.FindElement(By.CssSelector("#checkout-cart-wrapper p em"));
        }
Example #4
0
        public void WaitForElementTextChange(string cssSelector, string elementText)
        {
            By       selector    = By.CssSelector(cssSelector);
            TimeSpan fromSeconds = TimeSpan.FromSeconds(20);

            new WebDriverWait(WebDriver, fromSeconds).Until(ExpectedConditions.InvisibilityOfElementWithText(selector, elementText));
        }
Example #5
0
 public void  DeleteAllProductsInCart()
 {
     ProductsWithShortcut[0].Click();
     while (RemoveButtonsList.Count > 0)
     {
         var currentRemovedProduct               = driver.FindElement(By.XPath("//*[@name='remove_cart_item']"));
         var currentNumberOfRemoveButtons        = GetRemoveButtons().Count;
         var currentNumberOfProductsWithShortkut = GetProductsWithShortcut().Count;
         var removedProductName     = driver.FindElement(By.XPath("//*[@name='remove_cart_item']/../..//a")).Text;
         var quantityRemovedProduct = driver.FindElement(By.Name("quantity"));
         if (int.Parse(quantityRemovedProduct.GetAttribute("value")) > 1)
         {
             quantityRemovedProduct.Clear();
             quantityRemovedProduct.SendKeys("1");
         }
         RemoveBtn = GetRemoveButtonForProduct();
         RemoveBtn.Сlick();
         WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
         wait.Until(
             ExpectedConditions.InvisibilityOfElementWithText(By.CssSelector("[class ='dataTable rounded-corners'] td.item"), removedProductName));
         ProductsWithShortcut = GetProductsWithShortcut();
         RemoveButtonsList    = GetRemoveButtons();
         OrderSummaryItems    = GetOrderSummaryItems();
     }
 }
Example #6
0
        public void ShouldSelectAnswers()
        {
            var driver = new ChromeDriver();

            driver.Navigate().GoToUrl(testUrl);

            var companySelectElement = driver.FindElement(By.Id("companySelect"));
            var carSelectElement     = driver.FindElement(By.Id("carSelect"));

            #region TEST CODE
            var waiter = new WebDriverWait(driver, TimeSpan.FromSeconds(11));

            var handyCompanySelectElement = new SelectElement(companySelectElement);
            handyCompanySelectElement.SelectByText("BMW");

            waiter.Until(ExpectedConditions.ElementToBeClickable(carSelectElement));

            var handyCarSelectElement = new SelectElement(carSelectElement);
            handyCarSelectElement.SelectByText("Sedan");

            waiter.Until(ExpectedConditions.InvisibilityOfElementWithText(By.Id("results"), "..."));
            #endregion

            Assert.AreEqual(driver.FindElements(By.ClassName("list-group-item")).Count(), 6);


            driver.Quit();
        }
Example #7
0
        public void NavigatingToCodeSprintersSite()
        {
            GoToGoogle();
            Search(TextToSearch);
            GoToSearchResultByPageTitle(PageTitle);


            Assert.Single(GetElementsByLinkText(LinkTextToFind));
            Assert.Single(GetElementsByLinkText(LinkTextToFind1));

            driver.FindElement(By.LinkText("Akceptuję")).Click();

            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(11));

            wait.Until(ExpectedConditions.InvisibilityOfElementWithText(By.LinkText("Akceptuję"), "Akceptuję"));

            WaitForClickable(By.LinkText("Poznaj nasze podejście"), 5);

            driver.FindElement(By.LinkText("Poznaj nasze podejście")).Click();

            // ver 1
            Assert.Contains("WIEDZA NA PIERWSZYM MIEJSCU", driver.PageSource);


            // ver 2
            Assert.Single(driver.FindElements(By.TagName("h2"))
                          .Where(tag => tag.Text == "WIEDZA NA PIERWSZYM MIEJSCU"));
        }
        public void BusketTest()
        {
            driver.Url = "http://localhost/litecart/en/";

            // Добавляем товары в корзину
            for (int i = 1; i <= 3; i++)
            {
                driver.FindElement(By.XPath("//*[@id='box-most-popular']//li[" + i + "]")).Click();
                if (elements.IsElementPresent(driver, By.XPath("//*[@id='box-product']//select")) == true)
                {
                    driver.FindElement(By.XPath("//*[@id='box-product']//select")).SendKeys("large" + Keys.Enter);
                }

                string before = driver.FindElement(By.XPath("//span[@class='quantity']")).Text;
                driver.FindElement(By.XPath("//button[@name='add_cart_product']")).Click();
                wait.Until(ExpectedConditions.InvisibilityOfElementWithText(By.XPath("//div[@id='cart']//span[@class='quantity']"), before));
                string after = driver.FindElement(By.XPath("//span[@class='quantity']")).Text;
                if (after != before)
                {
                    driver.FindElement(By.XPath("//a[@href ='http://localhost/litecart/en/']")).Click();
                }
            }

            driver.FindElement(By.XPath("//a[@class='link'][contains(text(),'Checkout »')]")).Click();
            driver.FindElement(By.XPath("//li[@class='shortcut'][1]")).Click();
            int productsInBusket = driver.FindElements(By.XPath("//*[@id='checkout-summary-wrapper']//tbody/tr/td[contains(@class,'item')]")).Count;

            for (int i = 1; i <= productsInBusket; i++)
            {
                string product = driver.FindElement(By.XPath("//*[@id='checkout-summary-wrapper']//tbody/tr/td[contains(@class,'item')]")).Text;
                driver.FindElement(By.XPath("//button[@type='submit'][contains(text(),'Remove')]")).Click();
                wait.Until(ExpectedConditions.InvisibilityOfElementWithText(By.XPath("//*[@id='checkout-summary-wrapper']//tbody/tr/td[contains(@class,'item')]"), product));
            }
            wait.Until(ExpectedConditions.ElementExists(By.XPath("//*[contains(text(),'There are no items in your cart.')]")));
        }
Example #9
0
 internal void DeleteWinnersWithTitle(string title)
 {
     TitleText = title;
     DeleteTitle.Click();
     ApproveRemove.Click();
     Waiter.Until(ExpectedConditions.InvisibilityOfElementWithText(PopupTitle, "Are you sure you want to remove winner?"));
 }
        protected static bool waitElementIsInvisibleByXPath(string xpath, string text)
        {
            bool          isVisible = false;
            WebDriverWait wait      = new WebDriverWait(driver, TimeSpan.FromSeconds(25));

            Assert.True(wait.Until(ExpectedConditions.InvisibilityOfElementWithText(By.XPath(xpath), text)));
            return(isVisible);
        }
Example #11
0
 public static void WaitElementUntilTextChanged(string xpath, int seconds)
 {
     if (Instance != null)
     {
         var sleep = new WebDriverWait(Instance, TimeSpan.FromSeconds(seconds));
         sleep.Until(ExpectedConditions.InvisibilityOfElementWithText(By.XPath(xpath), "New Wrestler"));
     }
 }
 private void WaitUntilPreviosProductShouldHaveDifferentTitle()
 {
     if (ProductList.Count != 0) //wait until previos product(if exist) should have different title
     {
         //Waiter.Until(ExpectedConditions.TextToBePresentInElement(FirstProductTitle,  ProductList[ProductList.Count - 1].Title));
         Waiter.Until(ExpectedConditions.InvisibilityOfElementWithText(ProductTitles, ProductList[ProductList.Count - 1].Title));
     }
 }
Example #13
0
        private void AcceptCookiePopup(string AcceptLinkText)
        {
            driver.FindElement(By.LinkText(AcceptLinkText)).Click();

            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(11));

            wait.Until(ExpectedConditions.InvisibilityOfElementWithText(By.LinkText(AcceptLinkText), AcceptLinkText));
        }
Example #14
0
        private void AcceptCookies()
        {
            driver.FindElement(By.LinkText(CookiesPolicy)).Click();

            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(11));

            wait.Until(ExpectedConditions.InvisibilityOfElementWithText(By.LinkText("Akceptuję"), "Akceptuję"));
        }
Example #15
0
        private void AcceptCookiePolicy()
        {
            By CookiePolicyButtonLocator = By.LinkText(CookiePolicyButtonText);

            driver.FindElement(CookiePolicyButtonLocator).Click();
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(11));

            wait.Until(ExpectedConditions.InvisibilityOfElementWithText(CookiePolicyButtonLocator, CookiePolicyButtonText));
        }
        private void AcceptCookiesPolicy()
        {
            driver.FindElement(By.LinkText(CookiePolicyAcceptButton)).Click();

            const int     MaxAnimationTime = 11;
            WebDriverWait wait             = new WebDriverWait(driver, TimeSpan.FromSeconds(MaxAnimationTime));

            wait.Until(ExpectedConditions.InvisibilityOfElementWithText(By.LinkText(CookiePolicyAcceptButton), CookiePolicyAcceptButton));
        }
Example #17
0
        private void AcceptCookiesAndOpenPage()
        {
            SearchAndClickWebElement(CookiesAcceptanceText);
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5));

            wait.Until(ExpectedConditions.InvisibilityOfElementWithText(By.LinkText(CookiesAcceptanceText), CookiesAcceptanceText));

            waitForElementPresent(By.LinkText(SearchText), 2);
            SearchAndClickWebElement(SearchText);
        }
        public void AddRatesByUserTest(string type, string datasetDifference)
        {
            loginPage.LoginToApplication(user, "NBV87^yu");

            var menu = new MenuPage(driver);

            var datasetName = $"{DatasetUserDescription(type)} {datasetDifference}";

            menu.DataMenuLocator.ClickEx(driver);

            menu.CarrierRatesAddMenuLocator.Click();

            var carrierAddPage = new CarrierRatesAddPage(driver);

            carrierAddPage.SelectDatasetButtonLocator.Click();

            carrierAddPage.SelectDataset(datasetName);

            Assert.AreEqual(carrierAddPage.SelectDatasetButtonLocator.Text, datasetName, "Dataset is not selected");

            carrierAddPage.CarrierNameTextBoxLocator.SendKeys($"User{randomString}");

            Assert.True(carrierAddPage.EnteredCarrierNameLocator.Text.Equals($"LUXFT-User{randomString}"), "Carrier name is not entered");

            uploadFile(PathToRates(type), driver);

            Utils.WaitUntilLoadingDisappears(driver, secondtToWait: 500);

            Assert.True(carrierAddPage.UploadedFileTextLocator.Text.Contains(fileRates), "File is not loaded");

            Utils.Scroll(carrierAddPage.FooterLocator, driver);

            carrierAddPage.StartButtonLocator.Click();

            waitQuick.Until(ExpectedConditions.ElementToBeClickable(carrierAddPage.ConfirmAddRatesButtonLocator)).Click();

            Utils.WaitUntilLoadingDisappears(driver, secondtToWait: 500);

            var dataProcessingStatus = new DataProcessingStatusPage(driver);

            Utils.WaitUntilLoadingDisappears(driver);

            dataProcessingStatus.CheckRefreshRateToMinimum();

            wait.Until(ExpectedConditions.InvisibilityOfElementWithText(By.XPath($"//*[@id='admin-table-office']//tr[1]/td[5]"), "In queue"));

            wait.Until(ExpectedConditions.InvisibilityOfElementWithText(By.XPath($"//*[@id='admin-table-office']//tr[1]/td[5]"), "In progress"));

            Utils.WaitBeforeAssert(driver);

            Assert.AreEqual("Completed successfully", dataProcessingStatus.UserStatus[0].Text, "Status is not Completed successfully");
        }
        public void CheckDeleteDatasetTest(string type, string datasetDifference)
        {
            loginPage.LoginToApplication();

            var menu = new MenuPage(driver);

            var datasetName = $"{DatasetUserDescription(type)} {datasetDifference}";

            menu.AdministrationMenuLocator.ClickEx(driver);

            menu.DatasetArchiveDeleteMenuLocator.Click();

            var datasetDeletePage = new DatasetDeletePage(driver);

            Utils.WaitUntilLoadingPlaceholderDisappears(driver);

            datasetDeletePage.SelectDatasetButtonLocator.Click();

            datasetDeletePage.SelectDataset(datasetName);

            Utils.WaitUntilLoadingDisappears(driver);

            Assert.AreEqual(datasetName, datasetDeletePage.SelectDatasetButtonLocator.Text, $"Dataset {datasetName} is not selected");

            datasetDeletePage.StartButtonLocator.Click();

            Utils.WaitUntilLoadingDisappears(driver);

            var dataProcessingStatus = new DataProcessingStatusPage(driver);

            Utils.WaitUntilLoadingDisappears(driver);

            dataProcessingStatus.CheckRefreshRateToMinimum();

            wait.Until(ExpectedConditions.InvisibilityOfElementWithText(By.XPath($"//*[@id='admin-table-office']//tr[1]/td[6]"), "In queue"));

            wait.Until(ExpectedConditions.InvisibilityOfElementWithText(By.XPath($"//*[@id='admin-table-office']//tr[1]/td[6]"), "In progress"));

            Utils.WaitBeforeAssert(driver);

            Assert.AreEqual("Completed successfully", dataProcessingStatus.Status[0].Text, "Status is not Completed successfully");
        }
        public void AddLossesByUserTest(string type, string datasetDifference)
        {
            loginPage.LoginToApplication(user, "NBV87^yu");

            var menu = new MenuPage(driver);

            var datasetName = $"{DatasetUserDescription(type)} {datasetDifference}";

            menu.DataMenuLocator.ClickEx(driver);

            menu.LossesAddMenuLocator.Click();

            var lossesAddPage = new LossesAddPage(driver);

            lossesAddPage.SelectDatasetButtonLocator.Click();

            lossesAddPage.SelectDataset(datasetName);

            Assert.AreEqual(lossesAddPage.SelectDatasetButtonLocator.Text, datasetName);

            UploadLosses(type, "LossUser1", driver);

            wait.Until(ExpectedConditions.ElementToBeClickable(lossesAddPage.StartButtonLocator)).Click();

            wait.Until(ExpectedConditions.ElementToBeClickable(lossesAddPage.ConfirmAddRatesButtonLocator)).Click();

            Utils.WaitUntilLoadingDisappears(driver, secondtToWait: 500);

            var dataProcessingStatus = new DataProcessingStatusPage(driver);

            Utils.WaitUntilLoadingDisappears(driver);

            dataProcessingStatus.CheckRefreshRateToMinimum();

            wait.Until(ExpectedConditions.InvisibilityOfElementWithText(By.XPath($"//*[@id='admin-table-office']//tr[1]/td[5]"), "In queue"));

            wait.Until(ExpectedConditions.InvisibilityOfElementWithText(By.XPath($"//*[@id='admin-table-office']//tr[1]/td[5]"), "In progress"));

            Utils.WaitBeforeAssert(driver);

            Assert.AreEqual("Completed successfully", dataProcessingStatus.UserStatus[0].Text, "Status is not Completed successfully");
        }
Example #21
0
        public void CheckCarrierRatesRemovingByAdminTest(string carrierName)
        {
            var menu = new MenuPage(driver);

            menu.DataMenuLocator.ClickEx(driver);

            menu.CarrierRatesRemoveMenuLocator.Click();

            var carrierRemovePage = new CarrierRatesRemovePage(driver);

            carrierRemovePage.SelectDatasetButtonLocator.Click();

            carrierRemovePage.SelectDataset(datasetDescription);

            carrierRemovePage.SelectCarrierButtonLocator.Click();

            carrierRemovePage.SelectCarrier(carrierName);

            waitQuick.Until(ExpectedConditions.ElementToBeClickable(carrierRemovePage.StartButtonLocator)).Click();

            waitQuick.Until(ExpectedConditions.ElementToBeClickable(carrierRemovePage.ConfirmRemoveRatesButtonLocator)).Click();

            Utils.WaitUntilLoadingDisappears(driver, secondtToWait: 500);

            var dataProcessingStatus = new DataProcessingStatusPage(driver);

            Utils.WaitUntilLoadingDisappears(driver);

            dataProcessingStatus.CheckRefreshRateToMinimum();

            wait.Until(ExpectedConditions.InvisibilityOfElementWithText(By.XPath($"//*[@id='admin-table-office']//tr[1]/td[6]"), "In queue"));

            wait.Until(ExpectedConditions.InvisibilityOfElementWithText(By.XPath($"//*[@id='admin-table-office']//tr[1]/td[6]"), "In progress"));

            Assert.Multiple(() =>
            {
                Assert.AreEqual("Completed successfully", dataProcessingStatus.Status[0].Text, "Status is not Completed successfully");
                Assert.AreEqual("Carrier Rates", dataProcessingStatus.DataType[0].Text, "Incorrect dataset type");
                Assert.AreEqual("Delete", dataProcessingStatus.RequestType[0].Text, "Incorrect request type");
            });
        }
        public void DeleteFromCart()
        {
            driver.FindElement(By.CssSelector("#cart a.content")).Click();
            List <IWebElement> tableItems = driver.FindElements(By.CssSelector("#order_confirmation-wrapper td.item")).ToList();
            int itemsCount = tableItems.Count;

            for (int i = itemsCount; i > 1; i--)
            {
                IWebElement el1     = driver.FindElement(By.CssSelector("table tr:nth-child(2) td.item"));
                string      el1text = el1.GetAttribute("textContent");

                driver.FindElement(By.Name("remove_cart_item")).Click();

                wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("table tr:nth-child(2) td.item")));
                wait.Until(ExpectedConditions.InvisibilityOfElementWithText(By.CssSelector("table tr:nth-child(2) td.item"), $"{el1text}"));
            }
            driver.FindElement(By.Name("remove_cart_item")).Click();
            wait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("#checkout-cart-wrapper a")));
            Thread.Sleep(1000);
            driver.FindElement(By.CssSelector("#checkout-cart-wrapper a")).Click();
        }
Example #23
0
        public string SkipSendMessage()
        {
            try
            {
                if (steam.FindElement(By.XPath("//*[@id=\"wizard_contents\"]/div/a[2]/span")).Text.Contains("Text an account verification code to my phone number ending"))
                {
                    steam.FindElement(By.XPath("//*[@id=\"wizard_contents\"]/div/a[3]/span")).Click();

                    System.Threading.Thread.Sleep(1000);
                    WebDriverWait wait = new WebDriverWait(steam, TimeSpan.FromSeconds(10));
                    wait.Until(ExpectedConditions.InvisibilityOfElementWithText(By.XPath("//*[@id=\"wizard_contents\"]/a[3]/span"), "I no longer have access to this phone number"));
                }
                return("Success");
            }
            catch (Exception error)
            {
                string log = String.Format("{0:dd/MM/yyyy HH:mm:ss}", DateTime.Now) + ". Error: " + error.ToString() + "\r\n" + GetInfo() + "\r\n";
                WriteBugLog(log);
                return(error.ToString());
            }
        }
Example #24
0
 /// <summary>
 /// Waits for an element containing text to disappear from the DOM
 /// </summary>
 /// <param name="locator">The locator for the element for which to wait</param>
 /// <param name="text">The text that should be found in the element</param>
 public void WaitForInvisibilityOfElementWithText(By locator, string text)
 {
     Locator = locator;
     try
     {
         bool wait = new WebDriverWait(Driver, Preferences.BaseSettings.Timeout)
                     .Until(ExpectedConditions
                            .InvisibilityOfElementWithText(locator, text));
         if (wait)
         {
             throw new TimeoutException("The invisibility of the element conatining the text specified cannot be ascertained.");
         }
     }
     catch (Exception ex)
     {
         if (_debugLevel == EnumConsoleDebugLevel.Human)
         {
             Console.Out.WriteLine("Unable to complete wait for element correctly.");
         }
         HandleErrors(ex);
     }
 }
Example #25
0
        public void NavigatingToCodeSprintersSi()
        {
            GoToGoogle();

            Search(TextToSearch);
            GoToSearchResultByPageTitle();

            //// ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=@color | ]]

            var element = driver.FindElement(By.LinkText(LinkTextToFind));

            Assert.NotNull(element);
            CookieAcceptOnPage();;

            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(2)); //czeka 5 sekund aż nie zniknie

            wait.Until(ExpectedConditions.InvisibilityOfElementWithText(By.LinkText("Akceptuję"), "Akceptuję"));

            waitForElementPresent(By.LinkText("Poznaj nasze podejście"), 0);

            Assert.Single(GetWebElementsLinks());

            driver.FindElement(By.LinkText("Poznaj nasze podejście")).Click();

            //System.Threading.Thread.Sleep(2);//czeka zawsze 2 sekundy



            //ver 1
            Assert.Contains("WIEDZA NA PIERWSZYM MIEJSCU", driver.PageSource);//wyszukiwanie tekstu na stronie

            //ver2

            Assert.Single(driver.FindElements(By.TagName("h2"))
                          .Where(tag => tag.Text == "WIEDZA NA PIERWSZYM MIEJSCU"));
            //wyszukuje tagi o nazwie h2, w zwróconej kolekcji tagów wyszukuje tekstu XXX
            //single -> sprawdza czy w zwróconej kolekcji jest dokładnie 1 element
        }
Example #26
0
        /// <summary>
        /// An expectation to wait and check that the web element with text is either invisible or not present on the DOM.
        /// </summary>
        /// <param name="locator">Locator for the web element.</param>
        /// <param name="text">The text of an element.</param>
        /// <param name="waitType">Type of wait from <see cref="WaitType"/>.</param>
        public void WaitForElementWithTextToBeInvisible(By locator, string text, WaitType waitType)
        {
            bool result = false;

            try
            {
                TimeSpan      time = GetWait(waitType);
                WebDriverWait wait = new WebDriverWait(Driver, time);
                result = wait.Until(ExpectedConditions.InvisibilityOfElementWithText(locator, text));
                if (!result)
                {
                    throw new WebDriverTimeoutException();
                }
            }
            catch (WebDriverTimeoutException e)
            {
                string message = string.Format(" Failed due to the text '{0}' in the element '{1}' is not disappeared in given wait time", text, locator);
                CustomExceptionHandler.CustomException(e, message);
            }
            catch (Exception e)
            {
                CustomExceptionHandler.CustomException(e);
            }
        }
Example #27
0
        private void WaitUntilPopupInvisible(By by, IWebDriver driver, int seconds)
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(seconds));

            wait.Until(ExpectedConditions.InvisibilityOfElementWithText(By.LinkText("Akceptuję"), "Akceptuję"));
        }
Example #28
0
 protected bool WaitForElementInVisibleByText(By lookupBy, string textValue, int maxWaitTime = 0)
 {
     maxWaitTime = maxWaitTime > 0 ? maxWaitTime : ElementSyncTimeOut;
     try
     {
         return(new WebDriverWait(Driver, TimeSpan.FromSeconds(maxWaitTime)).Until(ExpectedConditions.InvisibilityOfElementWithText(lookupBy, textValue)));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.InnerException.Message);
     }
 }
Example #29
0
        private void WaitForInvisible(string linktext)
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(11));

            wait.Until(ExpectedConditions.InvisibilityOfElementWithText(By.LinkText(linktext), linktext));
        }
Example #30
0
 public void WaitForInvisibilityOfElementWithText(string text, int?timeout = null) =>
 WaitHelper.GetExplicitWait(timeout == null ? Timeout : TimeSpan.FromMilliseconds((int)timeout))
 .Until(ExpectedConditions.InvisibilityOfElementWithText(_by, text));