internal void TryRestoreScrollbars()
 {
     if (configuration_.HideScrollbars)
     {
         ((EyesWebDriverTargetLocator)driver_.SwitchTo()).Frames(frameChain_);
         FrameChain fc = frameChain_.Clone();
         if (fc.Count > 0)
         {
             while (fc.Count > 0)
             {
                 Frame frame = fc.Pop();
                 frame.ReturnToOriginalOverflow(driver_);
                 EyesWebDriverTargetLocator.ParentFrame(logger_, driver_.RemoteWebDriver.SwitchTo(), fc);
             }
         }
         else
         {
             if (originalOverflow_ != null)
             {
                 logger_.Verbose("returning overflow of element to its original value: {0}", scrollRootElement_);
                 EyesSeleniumUtils.SetOverflow(originalOverflow_, driver_, scrollRootElement_);
             }
         }
         ((EyesWebDriverTargetLocator)driver_.SwitchTo()).Frames(frameChain_);
         logger_.Verbose("done restoring scrollbars.");
     }
     else
     {
         logger_.Verbose("no need to restore scrollbars.");
     }
 }
Exemple #2
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);
        }
        internal void TryHideScrollbars(bool stitchContent, IWebElement scrollRootElement)
        {
            if (configuration_.HideScrollbars)
            {
                scrollRootElement_ = scrollRootElement;
                frameChain_        = driver_.GetFrameChain().Clone();
                if (frameChain_.Count > 0)
                {
                    FrameChain fc = frameChain_.Clone();

                    // for the target frame, we only wish to remove scrollbars when in "fully" mode.
                    if (stitchContent)
                    {
                        Frame frame = fc.Peek();
                        frame.HideScrollbars(driver_);
                    }

                    RemoveScrollbarsFromParentFrames_(logger_, fc, driver_);
                }
                else
                {
                    logger_.Verbose("hiding scrollbars of element: {0}", scrollRootElement);
                    originalOverflow_ = EyesSeleniumUtils.SetOverflow("hidden", driver_, scrollRootElement);
                }

                logger_.Verbose("switching back to original frame");
                ((EyesWebDriverTargetLocator)driver_.SwitchTo()).Frames(frameChain_);

                logger_.Verbose("done hiding scrollbars.");
            }
            else
            {
                logger_.Verbose("no need to hide scrollbars.");
            }
        }
Exemple #5
0
        /// <summary>
        /// Returns the viewport size of the default content (outer most frame).
        /// </summary>
        /// <param name="forceQuery">If true, we will perform the query even if we have a cached viewport size.</param>
        /// <returns>The viewport size of the default content (outer most frame).</returns>
        public Size GetDefaultContentViewportSize(bool forceQuery = false)
        {
            Logger_.Verbose("GetDefaultContentViewportSize()");

            if (!defaultContentViewportSize_.IsEmpty && !forceQuery)
            {
                Logger_.Verbose("Using cached viewport size: {0}", defaultContentViewportSize_);
                return(defaultContentViewportSize_);
            }

            FrameChain currentFrames = frameChain_.Clone();

            if (currentFrames.Count > 0)
            {
                SwitchTo().DefaultContent();
            }

            Logger_.Verbose("Extracting viewport size...");
            defaultContentViewportSize_ = EyesSeleniumUtils.GetViewportSizeOrDisplaySize(Logger_, this);
            Logger_.Verbose("Done! Viewport size: {0}", defaultContentViewportSize_);

            if (currentFrames.Count > 0)
            {
                ((EyesWebDriverTargetLocator)SwitchTo()).Frames(currentFrames);
            }
            return(defaultContentViewportSize_);
        }
 private static void TryHideScrollbarsInFrame(Configuration config, EyesWebDriver driver, IWebElement rootElement)
 {
     if (config.HideScrollbars)
     {
         EyesSeleniumUtils.SetOverflow("hidden", driver, rootElement);
     }
 }
Exemple #7
0
        private IWebElement GetScrollRootElement(IWebDriver driver)
        {
            IWebElement scrollRootElement = ScrollRootElement;

            if (scrollRootElement == null)
            {
                logger_.Verbose("no scroll root element. selecting default.");
                scrollRootElement = EyesSeleniumUtils.GetDefaultRootElement(driver);
            }

            return(scrollRootElement);
        }
        internal int SwitchToTargetFrame_(ISeleniumCheckTarget checkTarget, Configuration config,
                                          List <FrameState> frameStates, IWebElement userDefinedSRE)
        {
            IList <FrameLocator> frameChain = checkTarget.GetFrameChain();

            foreach (FrameLocator frameLocator in frameChain)
            {
                IWebElement frameElement = EyesSeleniumUtils.FindFrameByFrameCheckTarget(frameLocator, driver_);
                MaximizeTargetFrameInCurrentFrame_(frameElement, userDefinedSRE);
                SwitchToFrame_(frameElement, frameLocator, config, frameStates);
            }
            return(frameChain.Count);
        }
        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);
        }
        private void PrepareParentFrames_()
        {
            if (originalFrameChain_.Count == 0)
            {
                return;
            }

            EyesWebDriverTargetLocator switchTo = (EyesWebDriverTargetLocator)driver_.SwitchTo();
            FrameChain fc = originalFrameChain_.Clone();

            while (fc.Count > 0)
            {
                switchTo.ParentFrame();
                Frame       currentFrame = fc.Pop();
                IWebElement rootElement  = EyesSeleniumUtils.GetCurrentFrameScrollRootElement(driver_, null);
                SaveCurrentFrameState_(frameStates_, driver_, rootElement);
                MaximizeTargetFrameInCurrentFrame_(currentFrame.Reference, rootElement);
            }
            frameStates_.Reverse();
            switchTo.Frames(originalFrameChain_);
        }
Exemple #11
0
 public string SetOverflow(string value)
 {
     return(EyesSeleniumUtils.SetOverflow(value, eyesDriver_, this));
 }