示例#1
0
        private void ParserSelenium()
        {
            var wait = new WebDriverWait(_driver, _timeoutB);

            _driver.Navigate().GoToUrl(Url);
            Thread.Sleep(5000);
            wait.Until(dr =>
                       dr.FindElement(By.XPath(
                                          "//table[contains(@class, 'cellTableWidget')]//tbody/tr[starts-with(@class, 'cellTable')]")));
            ParsingList();
            for (var i = 0; i < Count; i++)
            {
                try
                {
                    wait.Until(dr =>
                               dr.FindElement(By.XPath("//div[@class = 'gwt-HTML']/a[. = '>']")));
                }
                catch (Exception)
                {
                    Log.Logger("This is last page, return");
                    return;
                }

                _driver.ExecutorJs(
                    "var elem = document.querySelectorAll('div.pages div.gwt-HTML'); elem[elem.length-2].click()");
                Thread.Sleep(5000);
                wait.Until(dr =>
                           dr.FindElement(By.XPath(
                                              "//table[contains(@class, 'cellTableWidget')]//tbody/tr[starts-with(@class, 'cellTable')]")));
                ParsingList();
            }
        }
        private void ParserSelenium()
        {
            _driver.Manage().Cookies.DeleteAllCookies();
            var wait = new WebDriverWait(_driver, _timeoutB);

            Auth(_driver, wait);
            _driver.Navigate().GoToUrl(_url);
            Thread.Sleep(5000);
            _driver.SwitchTo().DefaultContent();
            wait.Until(dr =>
                       dr.FindElement(By.XPath(
                                          "//div[@class = 'grid_content']/div[contains(@class, 'gridview_item')][1]/table/tbody")));
            ParsingList(1);
            for (var i = 0; i < Count; i++)
            {
                try
                {
                    wait.Until(dr =>
                               dr.FindElement(By.XPath("//div[@class = 'page_container']/span[contains(@class, 'next')]")));
                }
                catch (Exception)
                {
                    Log.Logger("This is last page, return");
                    return;
                }

                _driver.ExecutorJs(
                    "var elem = document.querySelectorAll('div.page_container span.next'); elem[0].click()");
                Thread.Sleep(5000);
                wait.Until(dr =>
                           dr.FindElement(By.XPath(
                                              "//div[@class = 'grid_content']/div[contains(@class, 'gridview_item')][1]/table/tbody")));
                ParsingList(i);
            }
        }
示例#3
0
        private void ParserSelenium()
        {
            var wait = new WebDriverWait(_driver, _timeoutB);

            _driver.Navigate().GoToUrl(Url);
            Thread.Sleep(5000);
            wait.Until(dr =>
                       dr.FindElement(By.XPath(
                                          "//tbody/tr[@class = 'uan-table-border__tr']")));
            ParsingList();
            for (var i = 1; i < Count; i++)
            {
                try
                {
                    //_driver.FindElement(By.XPath($"//ul[contains(@class, 'uk-pagination')]//a[. = '{i}']")).Click();
                    _driver.ExecutorJs(
                        $"var elem = document.querySelectorAll('ul.uk-pagination a'); elem[{i}].click()");
                    Thread.Sleep(5000);
                    wait.Until(dr =>
                               dr.FindElement(By.XPath(
                                                  "//tbody/tr[@class = 'uan-table-border__tr']")));
                    ParsingList();
                }
                catch (Exception e)
                {
                    Log.Logger(e);
                }
            }
        }
 private void clicker(WebDriverWait wait)
 {
     wait.Until(dr =>
                dr.FindElement(By.XPath(
                                   "//button[contains(., 'Показать еще')]")));
     Thread.Sleep(2000);
     _driver.SwitchTo().DefaultContent();
     _driver.ExecutorJs(
         "var elem = document.querySelectorAll('button[x-show=\"nextPage !== false\"]'); elem[0].click()");
     //_driver.FindElement(By.XPath("//button[contains(., 'Показать еще')]")).Click();
 }
示例#5
0
        private void ParsingNextPage()
        {
            var wait = new WebDriverWait(_driver, _timeoutB);

            for (var i = 1; i <= Count; i++)
            {
                try
                {
                    //_driver.Clicker("//td[contains(., 'Перейти на страницу:')]//a[. = '>']");
                    _driver.ExecutorJs(
                        "var elem = document.querySelectorAll('#MainContent_dgProducts > tbody > tr:nth-child(1) > td > a.NotVisitedLink'); elem[elem.length-1].click()");
                    Thread.Sleep(5000);
                    wait.Until(dr =>
                               dr.FindElement(
                                   By.XPath("//table[@id = 'MainContent_dgProducts']//tr[contains(@class, 'ltint')][20]")));
                    _driver.SwitchTo().DefaultContent();
                    ParserFirstPage();
                }
                catch (Exception e)
                {
                    Log.Logger(e);
                }
            }
        }