Exemple #1
0
 public Eyes()
 {
     runner_ = new ClassicRunner();
     configuration_.SetForceFullPageScreenshot(false);
     seleniumEyes_ = new SeleniumEyes(this, (ClassicRunner)runner_);
     activeEyes_   = seleniumEyes_;
 }
Exemple #2
0
 public static IImageProvider GetImageProvider(UserAgent ua, SeleniumEyes eyes, Logger logger, ITakesScreenshot tsInstance)
 {
     if (ua != null)
     {
         if (ua.Browser.Equals(BrowserNames.Firefox))
         {
             int.TryParse(ua.BrowserMajorVersion, out int firefoxMajorVersion);
             if (firefoxMajorVersion >= 48)
             {
                 return(new FirefoxScreenshotImageProvider(eyes, logger, tsInstance, ua));
             }
         }
         else if (ua.Browser.Equals(BrowserNames.Safari))
         {
             return(new SafariScreenshotImageProvider(eyes, logger, tsInstance, ua));
         }
         else if (ua.Browser.Equals(BrowserNames.IE))
         {
             return(new InternetExplorerScreenshotImageProvider(eyes, logger, tsInstance, ua));
         }
         else if (ua.OS.Equals(OSNames.Android))
         {
             return(new AndroidScreenshotImageProvider(eyes, logger, tsInstance, ua));
         }
     }
     return(new TakeScreenshotImageProvider(logger, tsInstance, ua));
 }
        //[Test]
        //[Ignore("fails if not set up correctly")]
        public void TestSetViewportSize()
        {
            ChromeOptions options = new ChromeOptions();

            options.AddArgument("disable-infobars");
            if (TestUtils.RUN_HEADLESS)
            {
                options.AddArgument("headless");
            }
            IWebDriver driver = new RemoteWebDriver(options);

            Size expectedSize = new Size(700, 499);

            try
            {
                driver.Url = "http://viewportsizes.com/mine/";

                SeleniumEyes.SetViewportSize(driver, expectedSize);

                Bitmap screenshot = BasicImageUtils.CreateBitmap(((ITakesScreenshot)driver).GetScreenshot().AsByteArray);
                screenshot.Save($@"{logsPath_}\TestSetViewportSize.png");

                Size actualSize = SeleniumEyes.GetViewportSize(driver);

                Assert.AreEqual(expectedSize, actualSize, "Sizes differ");
            }
            finally
            {
                driver.Quit();
            }
        }
Exemple #4
0
        internal EyesWebDriver(Logger logger, SeleniumEyes eyes, IUserActionsEyes userActionEyes, RemoteWebDriver driver)
        {
            ArgumentGuard.NotNull(logger, nameof(logger));
            //ArgumentGuard.NotNull(eyes, nameof(eyes));
            ArgumentGuard.NotNull(driver, nameof(driver));

            Logger_           = logger;
            Eyes              = eyes;
            UserActionsEyes   = userActionEyes;
            RemoteWebDriver   = driver;
            frameChain_       = new FrameChain(logger);
            executeCommandMI_ = driver.GetType().GetMethod("Execute", BindingFlags.Instance | BindingFlags.NonPublic);
            var  driverType     = driver.GetType();
            bool isAppiumDriver = false;
            var  dt             = driverType;

            while (dt != null && !isAppiumDriver)
            {
                isAppiumDriver = dt.Name.StartsWith("AppiumDriver`");
                dt             = dt.BaseType;
            }

            if (!isAppiumDriver)
            {
                executeCommandMI_ = driverType.GetMethod("Execute", BindingFlags.Instance | BindingFlags.NonPublic);
                var commandExecutorProperty = driverType.GetProperty("CommandExecutor", BindingFlags.Instance | BindingFlags.NonPublic);
                var commandExecutor         = (ICommandExecutor)commandExecutorProperty.GetValue(driver);
                commandExecutor.CommandInfoRepository.TryAddCommand("getSession", new CommandInfo("GET", "/session/{sessionId}/"));
            }

            Logger_.Verbose("Driver is {0}", driver.GetType());
        }
Exemple #5
0
 internal Eyes(IServerConnectorFactory serverConnectorFactory)
 {
     runner_ = new ClassicRunner();
     configuration_.SetForceFullPageScreenshot(false);
     seleniumEyes_ = new SeleniumEyes(this, (ClassicRunner)runner_, serverConnectorFactory);
     activeEyes_   = seleniumEyes_;
 }
Exemple #6
0
 public Eyes(Uri serverUrl)
 {
     ArgumentGuard.NotNull(serverUrl, nameof(serverUrl));
     runner_ = new ClassicRunner();
     configuration_.SetForceFullPageScreenshot(false);
     seleniumEyes_ = new SeleniumEyes(this, serverUrl, (ClassicRunner)runner_);
     activeEyes_   = seleniumEyes_;
 }
Exemple #7
0
 public Eyes(ILogHandler logHandler = null)
 {
     if (logHandler == null)
     {
         logHandler = NullLogHandler.Instance;
     }
     runner_ = new ClassicRunner(logHandler);
     configuration_.SetForceFullPageScreenshot(false);
     seleniumEyes_ = new SeleniumEyes(this, (ClassicRunner)runner_);
     activeEyes_   = seleniumEyes_;
 }
Exemple #8
0
 public Eyes(Uri serverUrl, ILogHandler logHandler = null)
 {
     ArgumentGuard.NotNull(serverUrl, nameof(serverUrl));
     if (logHandler == null)
     {
         logHandler = NullLogHandler.Instance;
     }
     runner_ = new ClassicRunner(logHandler);
     configuration_.SetForceFullPageScreenshot(false);
     seleniumEyes_ = new SeleniumEyes(this, serverUrl, (ClassicRunner)runner_);
     activeEyes_   = seleniumEyes_;
 }
Exemple #9
0
        internal EyesWebDriver(Logger logger, SeleniumEyes eyes, RemoteWebDriver driver)
        {
            ArgumentGuard.NotNull(logger, nameof(logger));
            //ArgumentGuard.NotNull(eyes, nameof(eyes));
            ArgumentGuard.NotNull(driver, nameof(driver));

            Logger_         = logger;
            Eyes            = eyes;
            RemoteWebDriver = driver;
            frameChain_     = new FrameChain(logger);

            Logger_.Verbose("Driver is {0}", driver.GetType());
        }
        private void SwitchToFrame_(IWebElement frameElement,
                                    ISeleniumFrameCheckTarget frameTarget, Configuration config, List <FrameState> frameStates)
        {
            ITargetLocator switchTo = driver_.SwitchTo();

            switchTo.Frame(frameElement);
            IWebElement rootElement = SeleniumEyes.GetScrollRootElementFromSREContainer(frameTarget, driver_);
            Frame       frame       = driver_.GetFrameChain().Peek();

            frame.ScrollRootElement = rootElement;
            SaveCurrentFrameState_(frameStates, driver_, rootElement);
            TryHideScrollbarsInFrame(config, driver_, rootElement);
            frame.ScrollRootElementInnerBounds = EyesRemoteWebElement.GetClientBoundsWithoutBorders(rootElement, driver_, logger_);
        }
        private void MaximizeTargetFrameInCurrentFrame_(IWebElement frameElement, IWebElement userDefinedSRE)
        {
            IWebElement currentFrameSRE = EyesSeleniumUtils.GetCurrentFrameScrollRootElement(driver_, userDefinedSRE);

            IPositionProvider positionProvider = SeleniumEyes.GetPositionProviderForScrollRootElement_(logger_, driver_,
                                                                                                       stitchMode_, userAgent_, currentFrameSRE);

            Rectangle frameRect = EyesRemoteWebElement.GetClientBoundsWithoutBorders(frameElement, driver_, logger_);

            if (stitchMode_ == StitchModes.Scroll)
            {
                Point pageScrollPosition = positionProvider.GetCurrentPosition();
                frameRect.Offset(pageScrollPosition);
            }
            positionProvider.SetPosition(frameRect.Location);
        }
Exemple #12
0
 public Eyes(EyesRunner runner)
 {
     if (runner == null)
     {
         runner = new ClassicRunner();
     }
     runner_ = runner;
     if (runner is VisualGridRunner visualGridRunner)
     {
         visualGridEyes_   = new VisualGridEyes(this, visualGridRunner);
         isVisualGridEyes_ = true;
         activeEyes_       = visualGridEyes_;
     }
     else
     {
         seleniumEyes_ = new SeleniumEyes(this, (ClassicRunner)runner);
         activeEyes_   = seleniumEyes_;
     }
     ServerConnector = runner.ServerConnector;
 }
Exemple #13
0
 public Eyes(EyesRunner runner)
 {
     if (runner == null)
     {
         runner = new ClassicRunner();
     }
     runner_ = runner;
     if (runner is VisualGridRunner visualGridRunner)
     {
         visualGridEyes_   = new VisualGridEyes(this, visualGridRunner);
         isVisualGridEyes_ = true;
         activeEyes_       = visualGridEyes_;
     }
     else
     {
         seleniumEyes_ = new SeleniumEyes(this, (ClassicRunner)runner);
         activeEyes_   = seleniumEyes_;
     }
     configuration_.SetForceFullPageScreenshot(isVisualGridEyes_);
 }
Exemple #14
0
 public FirefoxScreenshotImageProvider(SeleniumEyes eyes, Logger logger, ITakesScreenshot tsInstance, UserAgent userAgent)
     : base(logger, tsInstance, userAgent)
 {
     eyes_ = eyes;
 }
Exemple #15
0
 public FirefoxRegionPositionCompensation(SeleniumEyes eyes, Logger logger)
 {
     this.eyes   = eyes;
     this.logger = logger;
 }
Exemple #16
0
        internal static IRegionPositionCompensation GetRegionPositionCompensation(UserAgent userAgent, SeleniumEyes eyes, Logger logger)
        {
            if (userAgent != null)
            {
                if (userAgent.Browser.Equals(BrowserNames.Firefox))
                {
                    int.TryParse(userAgent.BrowserMajorVersion, out int firefoxMajorVersion);
                    if (firefoxMajorVersion >= 48)
                    {
                        return(new FirefoxRegionPositionCompensation(eyes, logger));
                    }
                }
                else if (userAgent.Browser.Equals(BrowserNames.Safari) && userAgent.OS.Equals(OSNames.MacOSX))
                {
                    return(new SafariRegionPositionCompensation());
                }
                else if (userAgent.Browser.Equals(BrowserNames.IE))
                {
                    return(new InternetExplorerRegionPositionCompensation());
                }
            }

            return(new NullRegionPositionCompensation());
        }
Exemple #17
0
 public SafariScreenshotImageProvider(SeleniumEyes eyes, Logger logger, ITakesScreenshot tsInstance, UserAgent userAgent)
     : base(eyes, logger, tsInstance, userAgent)
 {
 }
 public MobileScreenshotImageProvider(SeleniumEyes eyes, Logger logger, ITakesScreenshot tsInstance, UserAgent userAgent)
     : base(logger, tsInstance, userAgent)
 {
     eyes_       = eyes;
     jsExecutor_ = new SeleniumJavaScriptExecutor(eyes.GetDriver());
 }