public ScrollPositionProvider(Logger logger, IEyesJsExecutor executor, IWebElement scrollRootElement) { ArgumentGuard.NotNull(executor, nameof(executor)); ArgumentGuard.NotNull(scrollRootElement, nameof(scrollRootElement)); logger_ = logger; executor_ = executor; ScrolledElement = scrollRootElement; }
/// <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); }
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); }
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; }
public static string SelectRootElement(IEyesJsExecutor executeScript) { return(SelectRootElement_(executeScript, RETURN_STRING)); }
/// <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!")); }
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))); }
/// <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)); }
/// <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)); }
/// <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!"))); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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_); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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!"))); }
public LeanFTCssTranslatePositionProvider(IEyesJsExecutor executor) { ArgumentGuard.NotNull(executor, nameof(executor)); Executor_ = executor; }
/// <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;")); }
public MobileDeviceSizeAdjuster(IEyesJsExecutor jsExecutor) { string viewportMetaTagContent = (string)jsExecutor.ExecuteScript(GetViewportMetaTagContentScript); viewportMetaTag_ = ViewportMetaTag.ParseViewportMetaTag(viewportMetaTagContent); }
/// <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)); }
/// <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)); }
public JSHideScrollbarsProvider(IEyesJsExecutor executor) { ArgumentGuard.NotNull(executor, nameof(executor)); Executor_ = executor; }
/// <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()); }
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); } }
/// <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!")); }