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."); } }
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."); } }
/// <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 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); }
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_); }