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); }
//isn't workin' private Icon BytesToIcon(SiteNode node) { using (MemoryStream ms = new MemoryStream(node.Screenshot)) { return(new Icon(ms)); } }
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); }
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(); }
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); }
private void RemoveSameNodeNames(SiteNode siteNode) { var list = new List <IWebElement>(siteNode.Links); list.Distinct().ToList(); }
private SiteNode CreateRootNode() { var rootNode = new SiteNode(driver.Title, FindElements(), 0, TakeScreenshoot(), driver.Url); return(rootNode); }