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.");
            }
        }
Пример #2
0
        /// <summary>
        /// Switches into every frame in the list. This is used as way to switch into nested frames in a single call.
        /// </summary>
        /// <param name="framesPath">The path to the frame to check. This is a list of frame names/IDs (where each frame is nested in the previous frame).</param>
        /// <returns>The WebDriver with the switched context.</returns>
        public IWebDriver Frames(string[] framesPath)
        {
            logger_.Log(TraceLevel.Debug, Stage.General, StageType.Called);
            ITargetLocator targetLocator = driver_.SwitchTo();

            foreach (string frameNameOrId in framesPath)
            {
                targetLocator.Frame(frameNameOrId);
            }
            return(driver_);
        }
        /// <summary>
        /// Switches into every frame in the list. This is used as way to switch into nested frames in a single call.
        /// </summary>
        /// <param name="framesPath">The path to the frame to check. This is a list of frame names/IDs (where each frame is nested in the previous frame).</param>
        /// <returns>The WebDriver with the switched context.</returns>
        public IWebDriver Frames(string[] framesPath)
        {
            logger_.Verbose("(framesPath)");
            ITargetLocator targetLocator = driver_.SwitchTo();

            foreach (string frameNameOrId in framesPath)
            {
                logger_.Debug("Switching to frame '{0}'...", frameNameOrId);
                targetLocator.Frame(frameNameOrId);
            }
            logger_.Verbose("Done switching into nested frames!");
            return(driver_);
        }
Пример #4
0
        public void SendKeys(string keySequence)
        {
            // We try to use the active element to get the region.
            IWebElement activeElement = eyesDriver_.SwitchTo().ActiveElement();

            eyesDriver_.UserActionsEyes.AddKeyboardTrigger(activeElement, keySequence);
            keyboard_.SendKeys(keySequence);
        }
        private static void RemoveScrollbarsFromParentFrames_(Logger logger, FrameChain fc, EyesWebDriver driver)
        {
            logger.Verbose("enter");
            driver.SwitchTo().ParentFrame();
            fc.Pop();
            Frame frame = fc.Peek();

            while (fc.Count > 0)
            {
                logger.Verbose("fc.Count = {0}", fc.Count);
                frame.HideScrollbars(driver);
                driver.SwitchTo().ParentFrame();
                fc.Pop();
                frame = fc.Peek();
            }

            logger.Verbose("exit");
        }
 internal void RestoreCaret()
 {
     if (configuration_.HideCaret && activeElement_ != null)
     {
         logger_.Verbose("Restoring caret. driver_.FrameChain.Count: {0}", driver_.GetFrameChain().Count);
         ((EyesWebDriverTargetLocator)driver_.SwitchTo()).Frames(frameChain_);
         driver_.ExecuteScript("arguments[0].focus();", activeElement_);
     }
 }
        public void Restore()
        {
            EyesWebDriverTargetLocator switchTo = (EyesWebDriverTargetLocator)driver_.SwitchTo();

            switchTo.Frames(frameChain_);

            cssPositionProvider_.RestoreState(cssMemento_);
            scrollPositionProvider_.RestoreState(scrollMemento_);
            driver_.ExecuteScript($"arguments[0].style.overflow='{overflow_}'", scrolledElement_);
        }
Пример #8
0
        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_);
        }
Пример #9
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);
        }
        private Point CalcFrameLocationInScreenshot_(FrameChain frameChain, ScreenshotTypeEnum screenshotType)
        {
            EyesWebDriverTargetLocator switchTo = (EyesWebDriverTargetLocator)driver_.SwitchTo();
            FrameChain currentFC = frameChain.Clone();

            switchTo.DefaultContent();
            Point locationInScreenshot = Point.Empty;

            foreach (Frame frame in currentFC)
            {
                Rectangle          rect           = ((EyesRemoteWebElement)frame.Reference).GetClientBounds();
                SizeAndBorders     sizeAndBorders = ((EyesRemoteWebElement)frame.Reference).SizeAndBorders;
                RectangularMargins borders        = sizeAndBorders.Borders;
                rect.Offset(borders.Left, borders.Top);
                locationInScreenshot.Offset(rect.Location);
                switchTo.Frame(frame.Reference);
            }

            return(locationInScreenshot);
        }