Example #1
0
        public ReadOnlyCollection <IWebElement> FindElements(By by)
        {
            IEnumerable <IWebElement> foundWebElementsList = RemoteWebDriver.FindElements(by);

            // This list will contain the found elements wrapped with our class.
            List <IWebElement> eyesWebElementsList = new List <IWebElement>();

            // TODO - Daniel, Support additional implementation of web element
            foreach (IWebElement element in foundWebElementsList)
            {
                if (element is RemoteWebElement && !(element is EyesRemoteWebElement))
                {
                    EyesRemoteWebElement erwe = new EyesRemoteWebElement(Logger_, this, element);
                    eyesWebElementsList.Add(erwe);
                    string id = EyesSeleniumUtils.GetElementIdForDictionary(element, RemoteWebDriver);
                    elementsFoundSinceLastNavigation_[id] = erwe;
                }
                else
                {
                    eyesWebElementsList.Add(element);
                    string id = EyesSeleniumUtils.GetElementIdForDictionary(element, RemoteWebDriver);
                    elementsFoundSinceLastNavigation_[id] = element;
                }
            }
            return(eyesWebElementsList.AsReadOnly());
        }
        private Size GetFrameContentSize()
        {
            IWebElement frameScrollRootElement = EyesSeleniumUtils.GetDefaultRootElement(driver_);
            Size        sreSize = EyesRemoteWebElement.GetClientSize(frameScrollRootElement, driver_, logger_);

            return(sreSize);
        }
        private void WillSwitchToFrame_(IWebElement targetFrame)
        {
            ArgumentGuard.NotNull(targetFrame, nameof(targetFrame));
            if (!(targetFrame is EyesRemoteWebElement eyesFrame))
            {
                eyesFrame = new EyesRemoteWebElement(logger_, driver_, targetFrame);
            }

            Point pl = targetFrame.Location;
            Size  ds = targetFrame.Size;

            SizeAndBorders     sizeAndBorders = eyesFrame.SizeAndBorders;
            RectangularMargins borderWidths   = sizeAndBorders.Borders;
            Size clientSize = sizeAndBorders.Size;

            Rectangle bounds = eyesFrame.GetClientBounds();

            Point contentLocation = new Point(bounds.X + borderWidths.Left, bounds.Y + borderWidths.Top);
            //Point originalLocation = ScrollPositionProvider.GetCurrentPosition(jsExecutor_, driver_.FindElement(By.TagName("html")));
            Point originalLocation = eyesFrame.ScrollPosition;

            Frame frame = new Frame(logger_, targetFrame,
                                    contentLocation,
                                    new Size(ds.Width, ds.Height),
                                    clientSize,
                                    originalLocation,
                                    bounds,
                                    borderWidths,
                                    jsExecutor_);

            driver_.GetFrameChain().Push(frame);
        }
Example #4
0
        public IWebElement FindElement(By by)
        {
            // TODO - Daniel, support additional implementations of WebElement.
            IWebElement webElement = RemoteWebDriver.FindElement(by);
            string      id;

            if (webElement is RemoteWebElement remoteWebElement && !(webElement is EyesRemoteWebElement))
            {
                webElement = new EyesRemoteWebElement(Logger_, this, remoteWebElement);
            }
Example #5
0
 public ElementPositionProvider(Logger logger, EyesWebDriver driver, IWebElement element)
 {
     logger_ = logger;
     driver_ = driver;
     if (element is EyesRemoteWebElement eyesElement)
     {
         element_ = eyesElement;
     }
     else
     {
         element_ = new EyesRemoteWebElement(logger, driver, element);
     }
     logger_.Verbose(element.ToString());
 }
Example #6
0
        private void SwitchToFrame_(IWebElement frameElement,
                                    ISeleniumFrameCheckTarget frameTarget, Configuration config, List <FrameState> frameStates)
        {
            ITargetLocator switchTo = driver_.SwitchTo();

            switchTo.Frame(frameElement);
            IWebElement rootElement = SeleniumEyes.GetScrollRootElementFromSREContainer(frameTarget, driver_);
            Frame       frame       = driver_.GetFrameChain().Peek();

            frame.ScrollRootElement = rootElement;
            SaveCurrentFrameState_(frameStates, driver_, rootElement);
            TryHideScrollbarsInFrame(config, driver_, rootElement);
            frame.ScrollRootElementInnerBounds = EyesRemoteWebElement.GetClientBoundsWithoutBorders(rootElement, driver_, logger_);
        }
Example #7
0
        public void SendKeys(string keySequence)
        {
            var control = Rectangle.Empty;

            // We try to use the active element to get the region.
            IWebElement activeElement = eyesDriver_.SwitchTo().ActiveElement();

            if (activeElement is RemoteWebElement)
            {
                activeElement = new EyesRemoteWebElement(Logger, eyesDriver_, activeElement);
                control       = ((EyesRemoteWebElement)activeElement).GetBounds().ToRectangle();
            }

            eyesDriver_.Eyes.AddKeyboardTrigger(control, keySequence);
            keyboard_.SendKeys(keySequence);
        }
Example #8
0
        private void MaximizeTargetFrameInCurrentFrame_(IWebElement frameElement, IWebElement userDefinedSRE)
        {
            IWebElement currentFrameSRE = EyesSeleniumUtils.GetCurrentFrameScrollRootElement(driver_, userDefinedSRE);

            IPositionProvider positionProvider = SeleniumEyes.GetPositionProviderForScrollRootElement_(logger_, driver_,
                                                                                                       stitchMode_, userAgent_, currentFrameSRE);

            Rectangle frameRect = EyesRemoteWebElement.GetClientBoundsWithoutBorders(frameElement, driver_, logger_);

            if (stitchMode_ == StitchModes.Scroll)
            {
                Point pageScrollPosition = positionProvider.GetCurrentPosition();
                frameRect.Offset(pageScrollPosition);
            }
            positionProvider.SetPosition(frameRect.Location);
        }
Example #9
0
        private void WillSwitchToFrame_(IWebElement targetFrame)
        {
            ArgumentGuard.NotNull(targetFrame, nameof(targetFrame));
            if (!(targetFrame is EyesRemoteWebElement eyesFrame))
            {
                eyesFrame = new EyesRemoteWebElement(logger_, driver_, targetFrame);
            }

            Size ds = targetFrame.Size;

            SizeAndBorders     sizeAndBorders = eyesFrame.SizeAndBorders;
            RectangularMargins borderWidths   = sizeAndBorders.Borders;
            Size clientSize = sizeAndBorders.Size;

            Rectangle bounds = eyesFrame.GetClientBounds();

            Point contentLocation  = new Point(bounds.X + borderWidths.Left, bounds.Y + borderWidths.Top);
            Point originalLocation = eyesFrame.ScrollPosition;

            Frame frame = new Frame(logger_, targetFrame,
                                    contentLocation,
                                    new Size(ds.Width, ds.Height),
                                    clientSize,
                                    originalLocation,
                                    bounds,
                                    borderWidths,
                                    jsExecutor_);
            var activeElementBeforeSwitch = targetLocator_.ActiveElement();

            targetLocator_.Frame(targetFrame);
            var activeElementAfterSwitch = targetLocator_.ActiveElement();

            if (!activeElementAfterSwitch.Equals(activeElementBeforeSwitch))
            {
                driver_.GetFrameChain().Push(frame);
            }
            else
            {
                throw new Exception("Failed switching to frame.");
            }
        }