public IGEDriverState OpenElementInNewTab(IGEWebElement element) { Actions newTab = new Actions(_driver); int newTabIndex = _driver.WindowHandles.Count; newTab.KeyDown(Keys.LeftControl).Click(element as IWebElement).KeyUp(Keys.LeftControl).Build().Perform(); _driver.SwitchTo().Window(_driver.WindowHandles[newTabIndex]); return(this.CalculateState(_driver)); }
private void ShowElement(IGEWebElement elem) { var screenShot = this._webDriver.TakeScreenShot(elem); using (Image image = Image.Load(new MemoryStream(screenShot.ToArray()))) { image.Save((".\\Snapshot\\" + "title" + ".png")); } }
private string GetIdFromElement(IGEWebElement element) { var elementId = element.findUrls(); if (elementId != null) { return(elementId); } throw new Exception("multiply ids"); }
public void FindPriceOnParent(IGEWebElement element, string priceIdentify, IList <double> prices) { double result; string parentPriceText = element.Parent.Text; parentPriceText = this.getPriceFromText(parentPriceText, priceIdentify); if (this.TryParseTextAsPrice(out result, parentPriceText)) { prices.Add(result); } }
public IList <byte> TakeScreenShot(IGEWebElement element = null) { Screenshot screenshot = null; if (element == null) { screenshot = ((ITakesScreenshot)_driver).GetScreenshot(); } else { ((IJavaScriptExecutor)_driver).ExecuteScript("arguments[0].scrollIntoView(true);", element.SourceElement); screenshot = ((ITakesScreenshot)element.SourceElement).GetScreenshot(); } return(screenshot.AsByteArray.ToList()); }
public double ExtractPrice(IGEWebElement element) { for (int i = 0; i < identifiers.Count; i++) { string priceIdentify = identifiers[i]; var priceElementCandidates = element.FindElementsByContainsText(priceIdentify); var filteredPriceElement = priceElementCandidates.Where(x => x.Text != "").DistinctBy(x => x.Text).ToList(); var price = this.TrySeparatePricesFromTexts(filteredPriceElement, priceIdentify); if (price.HasValue) { return(price.Value); } } throw new Exception("can not find any price"); }