コード例 #1
0
        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));
        }
コード例 #2
0
ファイル: Watcher.cs プロジェクト: yardenGoldy/DiscountAlert
        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"));
            }
        }
コード例 #3
0
ファイル: Watcher.cs プロジェクト: yardenGoldy/DiscountAlert
        private string GetIdFromElement(IGEWebElement element)
        {
            var elementId = element.findUrls();

            if (elementId != null)
            {
                return(elementId);
            }
            throw new Exception("multiply ids");
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
        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());
        }
コード例 #6
0
        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");
        }