Beispiel #1
0
        private List <SiteNode> FindElementsFromSiteNode(SiteNode rootNode)
        {
            var elements         = rootNode.Links;
            var elementsToReturn = new List <SiteNode>();


            for (int i = 0; i < elements.Count; i++)
            {
                try
                {
                    elements = FindElements();
                    elementsToReturn.Add(CreateSiteNode(elements[i], rootNode.SiteNodeId));
                }
                catch (ArgumentOutOfRangeException ex)
                {
                    NewTabHandle();
                    elements = FindElements();
                    continue;
                }
                catch (InvalidOperationException ex2)    //Element generated by JS or being before element
                {
                    InvalidOperationHandle(elements[i], rootNode, elementsToReturn);
                }
            }
            return(elementsToReturn);
        }
Beispiel #2
0
 //isn't workin'
 private Icon BytesToIcon(SiteNode node)
 {
     using (MemoryStream ms = new MemoryStream(node.Screenshot))
     {
         return(new Icon(ms));
     }
 }
Beispiel #3
0
        private SiteNode CreateSiteNode(IWebElement element, int parentId)
        {
            element.Click();
            Thread.Sleep(500);
            var siteNode = new SiteNode(driver.Title, FindElements(), parentId, TakeScreenshoot(), driver.Url);



            driver.Navigate().Back();
            return(siteNode);
        }
Beispiel #4
0
        private void InvalidOperationHandle(IWebElement element, SiteNode node, List <SiteNode> listOfElements)
        {
            string prevNodeTitle   = driver.Title;
            IJavaScriptExecutor ex = (IJavaScriptExecutor)driver;

            ex.ExecuteScript("arguments[0].click();", element);

            SiteNode newNode;

            if (driver.Title == prevNodeTitle)  //if href is taking to the same site, then dont list it
            {
                return;
            }
            newNode = new SiteNode(driver.Title, FindElements(), node.ParentNodeId, TakeScreenshoot(), driver.Url);
            listOfElements.Add(newNode);    //?
            driver.Navigate().Back();
        }
Beispiel #5
0
        private List <SiteNode> FindElementsFromSiteNode(SiteNode rootNode, int indexToClick)
        {
            if (indexToClick > 0)  //after goin inside-back to prev node site
            {
                driver.Navigate().Back();
            }

            var elementsPrevNode = FindElements();
            //var elements = nodeAbove.GetAllLinks();
            var elementsToReturn = new List <SiteNode>();

            try
            {
                elementsPrevNode[indexToClick].Click();
            }
            catch (InvalidOperationException ex2)    //Element generatet by JS or being before element
            {
                //InvalidOperationHandle(elementsPrevNode[nodeNumber], elementsToReturn);
            }

            //maybbn
            var elements = rootNode.Links;

            for (int i = 0; i < elements.Count; i++)
            {
                try
                {
                    elements = FindElements();
                    elementsToReturn.Add(CreateSiteNode(elements[i], rootNode.SiteNodeId));
                }
                catch (ArgumentOutOfRangeException ex)
                {
                    NewTabHandle();
                    elements = FindElements();
                    continue;
                }
                catch (InvalidOperationException ex2)    //Element generated by JS or being before element
                {
                    InvalidOperationHandle(elements[i], rootNode, elementsToReturn);
                }
            }
            return(elementsToReturn);
        }
Beispiel #6
0
        private void RemoveSameNodeNames(SiteNode siteNode)
        {
            var list = new List <IWebElement>(siteNode.Links);

            list.Distinct().ToList();
        }
Beispiel #7
0
        private SiteNode CreateRootNode()
        {
            var rootNode = new SiteNode(driver.Title, FindElements(), 0, TakeScreenshoot(), driver.Url);

            return(rootNode);
        }