예제 #1
0
        public ScrollPositionProvider(Logger logger, IEyesJsExecutor executor, IWebElement scrollRootElement)
        {
            ArgumentGuard.NotNull(executor, nameof(executor));
            ArgumentGuard.NotNull(scrollRootElement, nameof(scrollRootElement));

            logger_         = logger;
            executor_       = executor;
            ScrolledElement = scrollRootElement;
        }
예제 #2
0
        /// <summary>
        /// Set the overflow of the document's body, and return the previous overflow value.
        /// </summary>
        /// <param name="overflow">The overflow to set.</param>
        /// <param name="executor">A JavaScript executor.</param>
        /// <param name="returnStr">The return string which the script should use.</param>
        /// <param name="rootElement">Can be either 'body' or 'documentElement'. Default is 'body'.</param>
        /// <returns>The previous overflow value.</returns>
        public static string SetOverflow_(string overflow, IEyesJsExecutor executor,
                                          string returnStr, string rootElement = null)
        {
            string returnAppliedStr = JSSetOverflow_.Replace(RETURN_PLACEHOLDER_, returnStr);
            string overflowStr      = returnAppliedStr.Replace("{0}", overflow).Replace("{1}", rootElement ?? "documentElement");
            var    result           = executor.ExecuteScript(overflowStr);

            Thread.Sleep(SetOverflowWaitMS_);
            return(result as string);
        }
예제 #3
0
        public static Size GetEntireSize(IWebElement element, IEyesJsExecutor jsExecutor, Logger logger = null)
        {
            logger.Verbose("enter (element: {0})", element);
            string entireSizeStr = (string)jsExecutor.ExecuteScript(JS_GET_ENTIRE_ELEMENT_SIZE, element);

            string[] wh   = entireSizeStr.Split(';');
            Size     size = new Size(Convert.ToInt32(wh[0]), Convert.ToInt32(wh[1]));

            logger.Verbose(size.ToString());
            return(size);
        }
예제 #4
0
        public Frame(Logger logger, IWebElement reference, Point location, Size outerSize, Size innerSize,
                     Point originalLocation, Rectangle bounds, RectangularMargins borderWidths, IEyesJsExecutor jsExecutor)
        {
            ArgumentGuard.NotNull(logger, nameof(logger));
            ArgumentGuard.NotNull(reference, nameof(reference));
            ArgumentGuard.NotNull(jsExecutor, nameof(jsExecutor));

            logger.Verbose("Frame(logger, {0}, {1}, {2}, {3}, {4})",
                           reference, location, outerSize, innerSize, originalLocation);

            logger_          = logger;
            Reference        = reference;
            Location         = location;
            OuterSize        = outerSize;
            InnerSize        = innerSize;
            OriginalLocation = originalLocation;
            Bounds           = bounds;
            BorderWidths     = borderWidths;
            positionMemento_ = new ScrollPositionMemento(originalLocation);
            jsExecutor_      = jsExecutor;
        }
예제 #5
0
 public static string SelectRootElement(IEyesJsExecutor executeScript)
 {
     return(SelectRootElement_(executeScript, RETURN_STRING));
 }
예제 #6
0
        /// <summary>
        /// Scrolls to the given position.
        /// </summary>
        /// <param name="scrollPosition">The position to scroll to.</param>
        /// <param name="executor">A JavaScript executor.</param>
        /// <param name="returnStr">The return string which the script should use.</param>
        /// <returns>The actual position the element had scrolled to.</returns>
        public static Point ScrollTo_(Point scrollPosition, IEyesJsExecutor executor, string returnStr)
        {
            var position = executor.ExecuteScript($"window.scrollTo({scrollPosition.X},{scrollPosition.Y});" + JSGetScrollPosition_.Replace(RETURN_PLACEHOLDER_, returnStr));

            return(ParseLocation(position, "Could not get scroll position!"));
        }
예제 #7
0
 public static string HideScrollbars(IEyesJsExecutor jsExecutor, string rootElement = null)
 {
     return(HideScrollbars_(jsExecutor, RETURN_STRING, rootElement));
 }
 public static IPositionProvider GetPositionProvider(Logger logger, StitchModes stitchMode, IEyesJsExecutor executor, IWebElement scrollRootElement, UserAgent userAgent = null)
 {
     return(positionProviders_.GetOrAdd(scrollRootElement + "_" + stitchMode,
                                        (e) => CreatePositionProvider(logger, stitchMode, executor, scrollRootElement, userAgent)));
 }
예제 #9
0
 /// <summary>
 /// Get the scroll position of the current frame.
 /// </summary>
 /// <param name="executor">A JavaScript executor.</param>
 /// <returns>The scroll position of the current frame.</returns>
 public static Point GetCurrentScrollPosition(IEyesJsExecutor executor)
 {
     return(GetCurrentScrollPosition_(executor, RETURN_STRING));
 }
예제 #10
0
 /// <summary>
 /// Sets a transform on the document's body, and return the previous transform value.
 /// </summary>
 /// <param name="transform">The transform to set.</param>
 /// <param name="executor">A JavaScript executor.</param>
 /// <returns>The previous transform value.</returns>
 public static object SetTranform(string transform, IEyesJsExecutor executor)
 {
     return(SetTranform_(transform, executor, RETURN_STRING));
 }
예제 #11
0
        /// <summary>
        /// Get the size of the entire page based on the scroll width/height.
        /// </summary>
        /// <param name="executeScript">A reference to a function for executing the script.</param>
        /// <param name="returnStr">The return string which the script should use.</param>
        /// <returns>The size of the entire page.</returns>
        public static Size GetCurrentFrameContentEntireSize_(IEyesJsExecutor executeScript, string returnStr)
        {
            var size = executeScript.ExecuteScript(JSReturnContentEntireSize_.Replace(RETURN_PLACEHOLDER_, returnStr));

            return(new Size(ParseLocation(size, "Could not get entire page size!")));
        }
예제 #12
0
 /// <summary>
 /// Set the overflow of the document's body, and return the previous overflow value.
 /// </summary>
 /// <param name="overflow">The overflow to set.</param>
 /// <param name="jsExecutor"></param>
 /// <returns>The previous overflow value.</returns>
 public static object SetOverflow(string overflow, IEyesJsExecutor jsExecutor)
 {
     return(SetOverflow_(overflow, jsExecutor, RETURN_STRING));
 }
예제 #13
0
 /// <summary>
 /// Hides the scrollbars.
 /// </summary>
 /// <param name="jsExecutor"></param>
 /// <returns>The original overflow value of the page.</returns>
 public static object HideScrollbars(IEyesJsExecutor jsExecutor)
 {
     return(HideScrollbars_(jsExecutor, RETURN_STRING));
 }
예제 #14
0
 /// <summary>
 /// CSS-translates the document body to the given position, and returns the previous
 /// transform value.
 /// </summary>
 /// <param name="position">The position to translate to.</param>
 /// <param name="executor">A JavaScript executor.</param>
 /// <returns>The previous transform value</returns>
 public static object TranslateTo(Point position, IEyesJsExecutor executor)
 {
     return(TranslateTo_(position, executor, RETURN_STRING));
 }
예제 #15
0
 /// <summary>
 /// Scrolls current frame to its bottom right.
 /// </summary>
 /// <param name="executor">The executor to use.</param>
 public static void ScrollToBottomRight(IEyesJsExecutor executor)
 {
     executor.ExecuteScript(JSScrollToBottomRight_);
 }
예제 #16
0
 /// <summary>
 /// Scrolls to the given position.
 /// </summary>
 /// <param name="scrollPosition">The position to scroll to.</param>
 /// <param name="executor">A JavaScript executor.</param>
 /// <returns>The actual position the element had scrolled to.</returns>
 public static Point ScrollTo(Point scrollPosition, IEyesJsExecutor executor)
 {
     return(ScrollTo_(scrollPosition, executor, RETURN_STRING));
 }
예제 #17
0
 /// <summary>
 /// Hides the scrollbars of the page, and returns the original overflow value.
 /// </summary>
 /// <param name="executor">A JavaScript executor.</param>
 /// <param name="returnStr">The return string which the script should use.</param>
 /// <param name="rootElement">Can be either 'body' or 'documentElement'. Default is 'body'.</param>
 /// <returns>The original overflow value of the page.</returns>
 public static string HideScrollbars_(IEyesJsExecutor executor, string returnStr, string rootElement = null)
 {
     return(SetOverflow_("hidden", executor, returnStr, rootElement));
 }
예제 #18
0
 /// <summary>
 /// Gets current document body's transform string.
 /// </summary>
 /// <returns>The transform string of the document body.</returns>
 public static object GetCurrentTransform(IEyesJsExecutor executor)
 {
     return(GetCurrentTransform_(executor, RETURN_STRING));
 }
예제 #19
0
        /// <summary>
        /// Get the size of the entire element based on the scroll width/height.
        /// </summary>
        /// <param name="executeScript">A reference to a function for executing the script.</param>
        /// <param name="returnStr">The return string which the script should use.</param>
        /// <param name="element">The element for which to take the size.</param>
        /// <returns>The size of the entire page.</returns>
        public static Size GetEntireElementSize_(IEyesJsExecutor executeScript, string returnStr, object element)
        {
            var size = executeScript.ExecuteScript(JSGetEntireElementSize_.Replace(RETURN_PLACEHOLDER_, returnStr), element);

            return(new Size(ParseLocation(size, "Could not get entire page size!")));
        }
예제 #20
0
        public LeanFTCssTranslatePositionProvider(IEyesJsExecutor executor)
        {
            ArgumentGuard.NotNull(executor, nameof(executor));

            Executor_ = executor;
        }
예제 #21
0
 /// <summary>
 /// Gets the device pixel ratio of the device running the hosting app.
 /// </summary>
 /// <returns>The Device pixel ratio.</returns>
 private static object GetDevicePixelRatio_(IEyesJsExecutor executeScript,
                                            string returnStr)
 {
     return(executeScript.ExecuteScript(returnStr + " window.devicePixelRatio;"));
 }
예제 #22
0
        public MobileDeviceSizeAdjuster(IEyesJsExecutor jsExecutor)
        {
            string viewportMetaTagContent = (string)jsExecutor.ExecuteScript(GetViewportMetaTagContentScript);

            viewportMetaTag_ = ViewportMetaTag.ParseViewportMetaTag(viewportMetaTagContent);
        }
예제 #23
0
 /// <summary>
 /// Get the size of the entire page based on the scroll width/height.
 /// </summary>
 /// <returns>The size of the entire page.</returns>
 public static Size GetEntirePageSize(IEyesJsExecutor executeScript)
 {
     return(GetEntirePageSize_(executeScript, RETURN_STRING));
 }
예제 #24
0
 /// <summary>
 /// Get the size of the entire page based on the scroll width/height.
 /// </summary>
 /// <returns>The size of the entire page.</returns>
 public static Size GetEntireElementSize(IEyesJsExecutor executeScript, object element)
 {
     return(GetEntireElementSize_(executeScript, RETURN_STRING, element));
 }
예제 #25
0
        public JSHideScrollbarsProvider(IEyesJsExecutor executor)
        {
            ArgumentGuard.NotNull(executor, nameof(executor));

            Executor_ = executor;
        }
예제 #26
0
 /// <summary>
 /// Get the size of the entire page based on the scroll width/height.
 /// </summary>
 /// <returns>The size of the entire frame content.</returns>
 public static Size GetCurrentFrameContentEntireSize(IEyesJsExecutor executeScript)
 {
     return(GetCurrentFrameContentEntireSize_(executeScript, RETURN_STRING));
 }
 public MobileScreenshotImageProvider(SeleniumEyes eyes, Logger logger, ITakesScreenshot tsInstance, UserAgent userAgent)
     : base(logger, tsInstance, userAgent)
 {
     eyes_       = eyes;
     jsExecutor_ = new SeleniumJavaScriptExecutor(eyes.GetDriver());
 }
예제 #28
0
 public static object GetDevicePixelRatio(IEyesJsExecutor executeScript)
 {
     return(GetDevicePixelRatio_(executeScript, RETURN_STRING));
 }
        public static IPositionProvider CreatePositionProvider(Logger logger, StitchModes stitchMode, IEyesJsExecutor executor, IWebElement scrollRootElement, UserAgent userAgent = null)
        {
            ArgumentGuard.NotNull(logger, nameof(logger));
            ArgumentGuard.NotNull(executor, nameof(executor));

            switch (stitchMode)
            {
            case StitchModes.CSS: return(new CssTranslatePositionProvider(logger, executor, scrollRootElement));

            case StitchModes.Scroll:
                if (userAgent != null && userAgent.Browser.Equals(BrowserNames.Edge))
                {
                    return(new EdgeBrowserScrollPositionProvider(logger, executor, scrollRootElement));
                }
                //else
                return(new ScrollPositionProvider(logger, executor, scrollRootElement));

            default:
                return(null);
            }
        }
예제 #30
0
        /// <summary>
        /// Get the scroll position of the current frame.
        /// </summary>
        /// <param name="executor">A JavaScript executor.</param>
        /// <param name="returnStr">The return string which the script should use.</param>
        /// <returns>The scroll position of the current frame.</returns>
        private static Point GetCurrentScrollPosition_(IEyesJsExecutor executor, string returnStr)
        {
            var position = executor.ExecuteScript(JSGetScrollPosition_.Replace(RETURN_PLACEHOLDER_, returnStr));

            return(ParseLocation(position, "Could not get scroll position!"));
        }