Exemplo n.º 1
0
        public void CollectLinks(Regex regExp, int maxDepth)
        {
            int count = _browser.FindElements(By.TagName("a")).Count;

            for (int i = 0; i < count; i++)
            {
                var webElement = _browser.FindElements(By.TagName("a")).ElementAtOrDefault(i);
                var child = new Page(_browser, webElement, this);
                Children.Add(child);

                var m = regExp.Match(child.Url.AbsoluteUri);
                if (m.Success && PageDepth < maxDepth)
                {
                    webElement.Click();
                    child.Source = _browser.PageSource;
                    child.CollectLinks(regExp, maxDepth);
                    _browser.Navigate().Back();
                }

            }
        }