示例#1
0
 public PageState(Logger logger, EyesWebDriver driver, StitchModes stitchMode, UserAgent userAgent)
 {
     logger_     = logger;
     driver_     = driver;
     stitchMode_ = stitchMode;
     userAgent_  = userAgent;
 }
示例#2
0
 private static void TryHideScrollbarsInFrame(Configuration config, EyesWebDriver driver, IWebElement rootElement)
 {
     if (config.HideScrollbars)
     {
         EyesSeleniumUtils.SetOverflow("hidden", driver, rootElement);
     }
 }
示例#3
0
        public EyesWebDriverScreenshot(Logger logger, EyesWebDriver driver, Bitmap image, ScreenshotTypeEnum?screenshotType, Point?frameLocationInScreenshot)
            : base(image)
        {
            ArgumentGuard.NotNull(logger, nameof(logger));
            ArgumentGuard.NotNull(driver, nameof(driver));
            logger_ = logger;
            driver_ = driver;

            logger_.Verbose("enter");

            UpdateScreenshotType_(screenshotType, image);

            IPositionProvider positionProvider;

            if (frameLocationInScreenshot == null || frameLocationInScreenshot.Value.IsEmpty)
            {
                IWebElement frameScrollRoot = driver.Eyes.GetCurrentFrameScrollRootElement();
                positionProvider = driver.Eyes.GetPositionProvider(logger, driver.Eyes.StitchMode,
                                                                   driver, frameScrollRoot);
                logger_.Verbose("position provider: using the current frame scroll root element's position provider: {0}", positionProvider);
            }
            else if (driver.Eyes.CurrentFramePositionProvider != null)
            {
                positionProvider = driver.Eyes.CurrentFramePositionProvider;
                logger_.Verbose("position provider: using CurrentFramePositionProvider: {0}", positionProvider);
            }
            else
            {
                positionProvider = driver.Eyes.PositionProvider;
                logger_.Verbose("position provider: using PositionProvider: {0}", positionProvider);
            }

            //IPositionProvider positionProvider = driver.Eyes.CurrentFramePositionProvider ?? driver.Eyes.PositionProvider;

            frameChain_ = driver_.GetFrameChain();
            logger_.Verbose("got frame chain. getting frame size...");
            Size frameSize = GetFrameSize_(positionProvider);

            UpdateCurrentScrollPosition_(positionProvider);
            UpdateFrameLocationInScreenshot_(frameLocationInScreenshot);
            Size frameContentSize = GetFrameContentSize();

            logger.Verbose("Calculating frame window...");
            frameWindow_ = new Region(frameLocationInScreenshot_, frameContentSize);
            Region imageSizeAsRegion = new Region(0, 0, image.Width, image.Height);

            logger.Verbose("frameWindow_: {0} ; imageSizeAsRegion: {1}", frameWindow_, imageSizeAsRegion);
            frameWindow_.Intersect(imageSizeAsRegion);
            logger.Verbose("updated frameWindow_: {0}", frameWindow_);

            if (frameWindow_.Width <= 0 || frameWindow_.Height <= 0)
            {
                throw new EyesException("Got empty frame window for screenshot!");
            }

            logger.Verbose("Done!");
        }
示例#4
0
        public EyesKeyboard(Logger logger, EyesWebDriver eyesDriver, IKeyboard keyboard)
        {
            ArgumentGuard.NotNull(logger, nameof(logger));
            ArgumentGuard.NotNull(eyesDriver, nameof(eyesDriver));
            ArgumentGuard.NotNull(keyboard, nameof(keyboard));

            Logger      = logger;
            eyesDriver_ = eyesDriver;
            keyboard_   = keyboard;
        }
示例#5
0
        public EyesMouse(Logger logger, EyesWebDriver eyesDriver, IMouse mouse)
        {
            ArgumentGuard.NotNull(logger, nameof(logger));
            ArgumentGuard.NotNull(eyesDriver, nameof(eyesDriver));
            ArgumentGuard.NotNull(mouse, nameof(mouse));

            Logger         = logger;
            eyesDriver_    = eyesDriver;
            mouse_         = mouse;
            mouseLocation_ = new Location(0, 0);
        }
 public EyesWebDriverTargetLocator(EyesWebDriver driver, Logger logger, ITargetLocator targetLocator)
 {
     driver_        = driver;
     logger_        = logger;
     targetLocator_ = targetLocator;
     jsExecutor_    = new SeleniumJavaScriptExecutor(driver_);
     if (driver.Eyes != null)
     {
         scrollPositionProvider_ = SeleniumPositionProviderFactory.GetPositionProvider(
             logger_, StitchModes.Scroll, jsExecutor_, driver.Eyes.GetCurrentFrameScrollRootElement(), driver.Eyes.userAgent_);
     }
 }
        internal static FrameState GetCurrentFrameState(EyesWebDriver driver, IWebElement scrolledElement)
        {
            IJavaScriptExecutor jsExecutor = driver;
            Logger    logger    = driver.Eyes.Logger;
            UserAgent userAgent = UserAgent.ParseUserAgentString(driver.GetUserAgent());

            IPositionProvider cssPositionProvider    = SeleniumPositionProviderFactory.GetPositionProvider(logger, StitchModes.CSS, driver, scrolledElement, userAgent);
            IPositionProvider scrollPositionProvider = SeleniumPositionProviderFactory.GetPositionProvider(logger, StitchModes.Scroll, driver, scrolledElement, userAgent);
            string            overflow   = (string)jsExecutor.ExecuteScript("return arguments[0].style.overflow", scrolledElement);
            FrameChain        frameChain = driver.GetFrameChain().Clone();
            FrameState        frameState = new FrameState(driver, scrolledElement, cssPositionProvider, scrollPositionProvider, overflow, frameChain);

            return(frameState);
        }
        public FrameState(EyesWebDriver driver, IWebElement scrolledElement, IPositionProvider cssPositionProvider, IPositionProvider scrollPositionProvider, string overflow, FrameChain frameChain)
        {
            driver_          = driver;
            scrolledElement_ = scrolledElement;

            cssPositionProvider_ = cssPositionProvider;
            cssMemento_          = cssPositionProvider_.GetState();

            scrollPositionProvider_ = scrollPositionProvider;
            scrollMemento_          = scrollPositionProvider_.GetState();

            overflow_   = overflow;
            frameChain_ = frameChain;
        }
示例#9
0
 public ElementPositionProvider(Logger logger, EyesWebDriver driver, IWebElement element)
 {
     logger_ = logger;
     driver_ = driver;
     if (element is EyesRemoteWebElement eyesElement)
     {
         element_ = eyesElement;
     }
     else
     {
         element_ = new EyesRemoteWebElement(logger, driver, element);
     }
     logger_.Verbose(element.ToString());
 }
 /// <summary>
 /// Create a frame(!) window screenshot
 /// </summary>
 /// <param name="logger"></param>
 /// <param name="driver"></param>
 /// <param name="image"></param>
 /// <param name="entireFrameSize"></param>
 public EyesWebDriverScreenshot(Logger logger, EyesWebDriver driver, Bitmap image, Size entireFrameSize, Point frameLocationInScreenshot)
     : base(image)
 {
     ArgumentGuard.NotNull(logger, nameof(logger));
     ArgumentGuard.NotNull(driver, nameof(driver));
     ArgumentGuard.NotNull(entireFrameSize, nameof(entireFrameSize));
     logger_     = logger;
     driver_     = driver;
     frameChain_ = driver_.GetFrameChain();
     // The frame comprises the entire screenshot.
     screenshotType_             = ScreenshotTypeEnum.ENTIRE_FRAME;
     currentFrameScrollPosition_ = new Point(0, 0);
     frameLocationInScreenshot_  = frameLocationInScreenshot;
     frameWindow_ = new Region(new Point(0, 0), entireFrameSize);
 }
示例#11
0
        public EyesRemoteWebElement(Logger logger, EyesWebDriver eyesDriver, IWebElement webElement)
            : base(eyesDriver.RemoteWebDriver, null)
        {
            ArgumentGuard.NotNull(logger, nameof(logger));
            ArgumentGuard.NotNull(eyesDriver, nameof(eyesDriver));
            ArgumentGuard.NotNull(webElement, nameof(webElement));

            Logger      = logger;
            eyesDriver_ = eyesDriver;
            webElement_ = webElement as RemoteWebElement;

            if (webElement_ == null)
            {
                string errMsg = "The input web element is not a RemoteWebElement ({0})"
                                .Fmt(webElement.GetType().Name);
                Logger.Log(errMsg);
                throw new EyesException(errMsg);
            }

            FieldInfo fi = typeof(RemoteWebElement).GetField("elementId", BindingFlags.NonPublic | BindingFlags.Instance);

            fi.SetValue(this, fi.GetValue(webElement));
        }
示例#12
0
        public static Point GetOffsetPositionFromActiveFrame(IWebElement targetElement, EyesWebDriver driver, Logger logger)
        {
            IWebElement activeFrame = driver.FindElement(By.TagName("html"));
            Point       afp         = GetScrollPosition(activeFrame, driver, logger);
            Point       elp         = GetOffsetPosition(targetElement, driver, logger);

            elp.Offset(afp);
            return(elp);
        }
        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");
        }
 public ScrollbarsVisibilityProvider(Logger logger, EyesWebDriver driver, Configuration configuration)
 {
     logger_        = logger;
     driver_        = driver;
     configuration_ = configuration;
 }
 public EyesWebDriverScreenshot(Logger logger, EyesWebDriver driver, Bitmap image)
     : this(logger, driver, image, default(ScreenshotTypeEnum), null)
 {
 }
示例#16
0
        private static void SaveCurrentFrameState_(List <FrameState> frameStates, EyesWebDriver driver, IWebElement rootElement)
        {
            FrameState frameState = FrameState.GetCurrentFrameState(driver, rootElement);

            frameStates.Add(frameState);
        }
 public SeleniumJavaScriptExecutor(EyesWebDriver driver)
 {
     jsExecutor_ = driver.RemoteWebDriver;
 }