/// <summary>
        /// Extrahiert die URL und speichert es in einer Liste ab
        /// </summary>
        /// <param name="driver">Selenium driver</param>
        private void AddUrl(IWebDriver driver)
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.CssSelector(".btn-sm")));
            IList <IWebElement> test = driver.FindElements(By.CssSelector(".btn-sm"));

            foreach (IWebElement b in test)
            {
                this.ListUrl.Add(new Uri(b.GetAttribute("href")));
            }
        }
Exemple #2
0
 public void WaitForElement(By by)
 {
     try
     {
         WebDriverWait wait = new WebDriverWait(this.driver, waitForElement);
         wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(by));
     }
     catch
     {
         throw new TimeoutException(string.Format("Element with locator: {0} was not found in {1} seconds!", by.ToString(), secondsToWait));
     }
 }
 public static void WaitForElement(string locator, IWebDriver driver)
 {
     try
     {
         SValues._wait = new WebDriverWait(driver, TimeSpan.FromSeconds(SValues.MaximunWaitTime));
         SValues._wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.XPath(locator)));
     }
     catch (WebDriverTimeoutException wdException)
     {
         SValues.Logger.Info("Failed trying to locate element : " + locator + " * Error Message * : " + wdException);
     }
 }
        public DarboPaieskosPage ReklamosUzdarymas()
        {
            WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(5));

            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("inner-border")));
            //TimeSpan.FromSeconds(2);
            if (ReklamosLangas.Displayed)
            {
                kryziukas.Click();
            }
            return(this);
        }
        public override TControl FindById <TControl>(string id, bool doWait = true)
        {
            var by = By.Id(id);

            if (doWait)
            {
                var wait = new WebDriverWait(GetBrowserPageObject(this).Browser, TimeSpan.FromMilliseconds(10000));
                wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(by));
                wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(by));
            }
            return(this.SearchContext.FindElement(by) as TControl);
        }
        public IWebElement FindByXPath(string xPath, bool doWait = true)
        {
            var by = By.XPath(xPath);

            if (doWait)
            {
                var wait = new WebDriverWait(GetBrowserPageObject(this).Browser, TimeSpan.FromMilliseconds(10000));
                wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(by));
                wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(by));
            }
            return(this.SearchContext.FindElement(by));
        }
        public IList <IWebElement> TableIdentifyRow(IWebElement webElement, string data)
        {
            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.CssSelector("td[role='gridcell']")));
            wait.Until(webDriver => webElement.Displayed);
            IWebElement         tablebody = webElement.FindElement(By.TagName("tbody"));
            List <IWebElement>  rows      = new List <IWebElement>(tablebody.FindElements(By.TagName("tr")));
            IWebElement         row       = rows.Where(item => item.Text.Contains(data)).FirstOrDefault();
            string              rowid     = row.GetAttribute("data-uid");
            IList <IWebElement> cells     = row.FindElements(By.TagName("td"));

            return(cells);
        }
Exemple #8
0
        public void ProccedByPassDica(IWebDriver driver)
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(20));

            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.XPath("//*[@id='ajax_login']/div/a")));
            driver.FindElement(By.XPath("//*[@id='ajax_login']/div/a")).Click();
            //driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.XPath("//*[@id='loginUsername']")));
            driver.FindElement(By.XPath("//*[@id='loginUsername']")).SendKeys("agencija KODEKS");
            driver.FindElement(By.XPath("//*[@id='loginPassword']")).SendKeys("1DvaTri4");
            driver.FindElement(By.XPath("//*[@id='btnLogin']")).Click();
        }
Exemple #9
0
        public void CST01ValidarLayoutTela()
        {
            //Thread.Sleep(5000);
            // EXPLICT WAIT
            //wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.CssSelector("#navbar > ul > li:nth-child(4) > a")));

            driver.FindElement(By.CssSelector("#navbar > ul > li:nth-child(4) > a")).Click();

            driver.SwitchTo().Frame(1);


            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.XPath("//*[@id='tbr_t0']/tbody/tr/td[2]")));

            driver.FindElement(By.XPath("//*[@id='tbr_t0']/tbody/tr/td[2]")).Click();

            driver.SwitchTo().Window(driver.WindowHandles[1]);


            //Page object

            Customer_Person_Edit customer = new Customer_Person_Edit();

            PageFactory.InitElements(driver, customer);

            //driver.FindElement(By.CssSelector("#nav-menu-item-5643 .item_text")).Click();

            //Thread.Sleep(5000);

            Assert.IsTrue(customer.name.Enabled);
            Assert.IsTrue(customer.taxid1.Enabled);
            Assert.IsTrue(customer.gender.Enabled);
            Assert.IsTrue(customer.telephone1.Enabled);
            Assert.IsTrue(customer.telephone2.Enabled);
            Assert.IsTrue(customer.telephone3.Enabled);
            Assert.IsTrue(customer.mobile.Enabled);
            Assert.IsTrue(customer.taxid2.Enabled);
            Assert.IsTrue(customer.nickname.Enabled);
            Assert.IsTrue(customer.fax.Enabled);
            Assert.IsTrue(customer.birthdate.Enabled);
            Assert.IsTrue(customer.cep.Enabled);
            Assert.IsTrue(customer.postalcode.Enabled);
            Assert.IsTrue(customer.address.Enabled);
            Assert.IsTrue(customer.addressline2.Enabled);
            Assert.IsTrue(customer.country.Enabled);
            Assert.IsTrue(customer.city.Enabled);
            Assert.IsTrue(customer.email1.Enabled);
            Assert.IsTrue(customer.email2.Enabled);
            Assert.IsTrue(customer.url.Enabled);
            Assert.IsTrue(customer.url_twitter.Enabled);
            Assert.IsTrue(customer.url_facebook.Enabled);
            Assert.IsTrue(customer.notes.Enabled);
        }
Exemple #10
0
        public void Broadband()
        {
            string bBand;

            excel.Workbook  xlWorkbook  = xlApp.Workbooks.Open("C:\\Passwords\\ExpensesDemo.xlsx");
            excel.Worksheet xlWorksheet = xlWorkbook.Sheets[1];
            excel.Range     xlRange     = xlWorksheet.UsedRange;

            Thread.Sleep(1000);

            bBand = xlRange.Cells[1][2].Value2.ToString();

            driver.FindElement(By.XPath(".//*[@id='add-item-links']/div/div/div[2]/div[2]/div/button")).Click();

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

            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("ExpenseParentCategoryId")));

            IWebElement week = driver.FindElement(By.Id("WeekEndingDateDisplay"));
            //week.SendKeys(Keys.ArrowDown);


            IWebElement internet = driver.FindElement(By.Id("ExpenseParentCategoryId"));

            internet.SendKeys(Keys.ArrowDown);
            internet.SendKeys(Keys.ArrowDown);
            internet.SendKeys(Keys.ArrowDown);
            internet.SendKeys(Keys.ArrowDown);

            //type
            IWebElement type = driver.FindElement(By.Id("ExpenseCategoryId"));

            type.SendKeys(Keys.ArrowDown);
            type.SendKeys(Keys.ArrowDown);
            type.SendKeys(Keys.ArrowDown);
            type.SendKeys(Keys.ArrowDown);

            // description
            driver.FindElement(By.Id("Description")).SendKeys("Broadband");

            //amount
            driver.FindElement(By.Id("GrossAmount")).Clear();

            driver.FindElement(By.Id("GrossAmount")).SendKeys(bBand);
            Thread.Sleep(1000);

            driver.FindElement(By.XPath("(//button[@type='button'])[2]")).Click();

            Thread.Sleep(1000);

            xlWorkbook.Close();
        }
Exemple #11
0
        public static void wait_for_element_exists_cssSel(string obj)
        {
            WebDriverWait wait = new WebDriverWait(SharedWebDriver.driver, TimeSpan.FromSeconds(10));

            if (string.Equals(browser, "safari", StringComparison.OrdinalIgnoreCase))
            {
                safari_wait_for_element(obj);
            }
            else
            {
                wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.CssSelector(obj)));
            }
        }
        public void ConsultarCEPPorLogradouro()
        {
            driver.Navigate().GoToUrl(baseURL);
            CEP_Page cep_page = new CEP_Page(driver);

            cep_page.ValidarCampos();
            cep_page.SelecionarUF();
            cep_page.DigitarLocalidade();
            cep_page.DigitarLogradouro();
            cep_page.ClicarBtnBuscar();
            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("resultado-DNEC")));
            cep_page.ValidarResultadoCEP();
        }
 /// <summary>
 /// Create an explicit wait for the element to become available
 /// </summary>
 /// <param name="selector">
 /// A Selenium By selector to query web elements from the page
 /// </param>
 /// <returns></returns>
 public virtual SEBaseElement AwaitElement(By selector)
 {
     try
     {
         WebDriverWait wait = new WebDriverWait(this, new TimeSpan(10 * TimeSpan.TicksPerSecond));
         wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(selector));
     }
     catch (WebDriverTimeoutException)
     {
         this.ReloadPage(selector);
     }
     return(new SEBaseElement(this.FindElement(selector)));
 }
        //Большинство драйверов не могут выполнить действия с элементом, если он невиден.
        //Вообще, они должны бы проверять условие ИНТЕРАКТИВНОСТИ,а не видимости, но для упрощения пока так.

        public void Method()
        {
            string locator = "q2345";
            //ждем пока элемент станет видимым
            //ВЫВОД - если метод из класс ExpectedConditions принимает ЛОКАТОР- то он вернет элемент
            var element        = wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(locator)));
            var listOfElements = driver.FindElements(By.CssSelector(locator));

            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(listOfElements));

            //ждем пока элемент станет невидимым
            wait.Until(ExpectedConditions.InvisibilityOfElementLocated(By.CssSelector(locator)));
        }
Exemple #15
0
 public static void WaitUntilElementVisibilityOfAllElment(IWebDriver driver, By path)
 {
     try
     {
         ReadOnlyCollection <IWebElement> myDynamicElementVisible = (new WebDriverWait(driver, TimeSpan.FromSeconds(TIMEOUT_WAIT_SECONDS)))
                                                                    .Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(path));
     }
     catch (TimeoutException e)
     {
         // TODO : log
         throw e;
     }
 }
        public DarboPaieskosPage IvestiNorimaAtlyginimoNuo(string atlyginimasNuo)
        {
            int atlyginimas = Convert.ToInt32(atlyginimasNuo);

            WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(100));

            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.XPath("//*[@id='slidecheck']")));
            IWebElement Slider = Driver.FindElement(By.XPath("//*[@id='slidecheck']"));

            SliderioStumimoTool.SliderioStumimas(Driver, Slider, atlyginimas, 3000, 0);
            TimeSpan.FromSeconds(2);
            return(this);
        }
        public void Confirmation()
        {
            var currentHandle            = ObjectRepository.Driver.CurrentWindowHandle;
            PopupWindowFinder finder     = new PopupWindowFinder(ObjectRepository.Driver);
            WebDriverWait     customWait = new WebDriverWait(ObjectRepository.Driver, TimeSpan.FromMinutes(2));

            customWait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.XPath(ExcelHelper.GetCellData(acr.GetXlpath(), "Details", 24, 1).ToString())));
            string popupWindowHandle = finder.Click(ObjectRepository.Driver.FindElement(By.XPath(ExcelHelper.GetCellData(acr.GetXlpath(), "Details", 24, 1).ToString())));

            ObjectRepository.Driver.SwitchTo().Window(popupWindowHandle);
            ObjectRepository.Driver.SwitchTo().Window(currentHandle);
            //ObjectRepository.Driver.FindElement(By.XPath(ExcelHelper.GetCellData(acr.GetXlpath(), "Details", 24, 1).ToString())).Click();
        }
Exemple #18
0
        public void RemoveAllItems()
        {
            var element = _wait.Until(ExpectedConditions.ElementToBeClickable(By.LinkText("Options")));

            element.Click();
            var buttons =
                _wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.ClassName("button")));

            buttons[1].Click();
            buttons = _wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.ClassName("button")));
            buttons[3].Click();
            _itemCounter = 0;
        }
 /// <summary>
 /// Create an explicit wait for the elements to become available
 /// </summary>
 /// <typeparam name="SEType"></typeparam>
 /// <param name="selector">
 /// A Selenium By selector to query web elements from the page
 /// </param>
 /// <returns></returns>
 public virtual List <SEType> AwaitElements <SEType>(By selector) where SEType : new()
 {
     try
     {
         WebDriverWait wait = new WebDriverWait(this, new TimeSpan(10 * TimeSpan.TicksPerSecond));
         wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(selector));
     }
     catch (WebDriverTimeoutException)
     {
         this.ReloadPage(selector);
     }
     return(this.FindElements(selector).Select(x => (SEType)Activator.CreateInstance(typeof(SEType), x)).ToList());
 }
Exemple #20
0
        public static IList <IWebElement> UntilListVisible(By by, IWebDriver driver, TimeSpan timeOut)
        {
            WebDriverWait wdWait = new WebDriverWait(driver, timeOut);

            wdWait.IgnoreExceptionTypes
            (
                typeof(ElementNotVisibleException),
                typeof(NoSuchElementException),
                typeof(StaleElementReferenceException)
            );

            return(wdWait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(by)));
        }
Exemple #21
0
 public static bool IsElementDisplayed(IWebElement element)
 {
     try
     {
         Driver.Wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy
                               (new ReadOnlyCollection <IWebElement>(new List <IWebElement>(new[] { element }))));
         return(true);
     }
     catch (WebDriverTimeoutException)
     {
         return(false);
     }
 }
Exemple #22
0
 private IWebElement awaitElement(By selector)
 {
     try
     {
         WebDriverWait wait = new WebDriverWait(this.driver, new TimeSpan(10 * TimeSpan.TicksPerSecond));
         wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(selector));
     }
     catch (WebDriverTimeoutException)
     {
         this.driver.ReloadPage(selector);
     }
     return(this.driver.FindElement(selector));
 }
        public static void WaitForElementToLoad(this IWebDriver driver, string attribute, int?timeoutInSeconds = null)
        {
            TimeSpan timeout = new TimeSpan(0, 0, 100);

            if (timeoutInSeconds.HasValue)
            {
                int timeoutInSecs = timeoutInSeconds.Value;
                timeout = new TimeSpan(0, 0, timeoutInSecs);
            }
            WebDriverWait wait = new WebDriverWait(driver, timeout);

            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id(attribute)));
        }
Exemple #24
0
        private void ClickSave()
        {
            WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(15));

            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.ClassName("save")));

            IWebElement         btnSave = this.Driver.FindElement(By.ClassName("save"));
            IJavaScriptExecutor ex      = (IJavaScriptExecutor)Driver;

            ex.ExecuteScript("window.scrollTo(0, 0) ", btnSave);
            Thread.Sleep(500);
            btnSave.Click();
        }
Exemple #25
0
        public void SetPageLoadTimeout()
        {
            // 2.1. Set Default Page Load Timeout
            this.driver.Manage().Timeouts().SetPageLoadTimeout(new TimeSpan(0, 0, 10));

            // 2.2. Wait Until Page is Fully Loaded via JS
            this.WaitUntilLoaded();

            // 2.3. Wait For Visibility of element
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));

            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.XPath("//*[@id='tve_editor']/div[2]/div[2]/div/div")));
        }
Exemple #26
0
        public void WaitForVisibility(TimeSpan?timeout = null)
        {
            var wait = new WebDriverWait(WebDriver, timeout ?? new TimeSpan(0, 0, 20));

            try
            {
                wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.XPath(XPath)));
            }
            catch (ElementNotVisibleException envex)
            {
                _logger.Error(envex, "Element not visible");
            }
        }
Exemple #27
0
        //public static IMyButton GetElement<T>(this ISearchContext element, By by)

        //{
        //    var test = element.GetElement<MyElement>(by, "test2");
        //    return test;
        //}

        public static T GetElement <T>(this ISearchContext searchContext, By by)
            where T : class
        {
            IWebDriver    d      = searchContext as IWebDriver;
            WebDriverWait waiter = new WebDriverWait(d, TimeSpan.FromSeconds(6));

            waiter.Until(ExpectedConditions.ElementExists(by));
            waiter.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(by));

            IWebElement webElemement = searchContext.FindElement(by);

            return(webElemement.As2 <T>(by, searchContext));
        }
Exemple #28
0
        public void ClosebrowserPrintPrice()
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("BaggageBundlingTemplate")));

            string minprice = driver.FindElementById("BaggageBundlingTemplate").Text;
            string flight   = driver.FindElementByCssSelector("#flightForm > section.resultsContainer > div.row.legsContainer > div > nav > ul > li.listItem.showTabs.nonBundled > table > tbody.segment > tr:nth-child(1) > th.vendor.count1 > small:nth-child(2)").Text;

            Console.WriteLine("Minimum price is  = " + minprice);
            Console.WriteLine("Airlines = " + flight);
            Console.Read();
        }
        private void ChO_BT_Click(object sender, RoutedEventArgs e)
        {
            Drv.Navigate().Refresh();
            System.Threading.Thread.Sleep(TimeSpan.FromSeconds(0.5));
            string numbOooo;

            try
            {
                WebDriverWait ww = new WebDriverWait(Drv, TimeSpan.FromSeconds(20));
                ww.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.XPath("//ul/li")));
                ReadOnlyCollection <IWebElement> colectionPage = Drv.FindElements(By.XPath("//ul/li"));
                int page = colectionPage.Count;

                for (int j = 0; j < (page - 2); j++)
                {
                    By xPathTitleOfTable             = By.XPath("//div[@aria-label='row']");
                    List <IWebElement> titleElements = AddToolsSe.getXpathElements(xPathTitleOfTable, ref Drv);
                    int count_elem = 1;
                    int count      = 0;
                    foreach (var item in titleElements)
                    {
                        int numbSymb = 10;
                        numbOooo = "";

                        for (int i = 0; i < numbSymb; i++)
                        {
                            if (item.Text[i] == '/')
                            {
                                break;
                            }
                            numbOooo += item.Text[i];
                        }
                        if (numbOooo == NO_TB.Text)
                        {
                            RocXPath(ref Drv, "//input[@type='checkbox']", out count)[count_elem].Click();
                            UATools.AllElemContainText(ref Drv, "*", "АА", "following-sibling::div/button").Click();
                            UATools.AllElemContainText(ref Drv, "*", "КК", "ancestor::span").Click();
                            numbOooo = NO_TB.Text = "";
                            return;
                        }
                        count_elem++;
                    }
                    UATools.Next(ref Drv, 10);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                numbOooo = NO_TB.Text = "";
            }
        }
Exemple #30
0
        public void MonthlyTrainPass()
        {
            string tPass;

            excel.Workbook  xlWorkbook  = xlApp.Workbooks.Open("C:\\Passwords\\ExpensesDemo.xlsx");
            excel.Worksheet xlWorksheet = xlWorkbook.Sheets[1];
            excel.Range     xlRange     = xlWorksheet.UsedRange;

            Thread.Sleep(1000);

            if (xlRange.Cells[9][2].Value2 != null)
            {
                tPass = xlRange.Cells[9][2].Value.ToString();
                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

                Thread.Sleep(1000);

                wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.XPath("//*[@id='add-receipted-item']")));
                driver.FindElement(By.XPath("//*[@id='add-receipted-item']")).Click();

                wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("ExpenseParentCategoryId")));

                IWebElement week = driver.FindElement(By.Id("WeekEndingDateDisplay"));

                week.SendKeys(Keys.ArrowUp);
                week.SendKeys(Keys.ArrowDown);


                IWebElement internet = driver.FindElement(By.Id("ExpenseParentCategoryId"));
                internet.SendKeys(Keys.ArrowDown);
                internet.SendKeys(Keys.ArrowDown);
                internet.SendKeys(Keys.ArrowDown);

                //type
                IWebElement type = driver.FindElement(By.Id("ExpenseCategoryId"));
                type.SendKeys(Keys.ArrowDown);

                // description
                driver.FindElement(By.Id("Description")).SendKeys("Train Pass to London");

                //amount
                driver.FindElement(By.Id("GrossAmount")).Clear();
                driver.FindElement(By.Id("GrossAmount")).SendKeys(tPass);
                Thread.Sleep(1000);

                driver.FindElement(By.XPath("(//button[@type='button'])[2]")).Click();

                Thread.Sleep(1000);
            }
            xlWorkbook.Close();
        }