Beispiel #1
0
        public void ViewportsTest()
        {
            WebDriverProvider       webdriverProvider      = new WebDriverProvider();
            IServerConnectorFactory serverConnectorFactory = new MockServerConnectorFactory(webdriverProvider);
            ILogHandler             logHandler             = TestUtils.InitLogHandler();
            VisualGridRunner        runner = new VisualGridRunner(30, nameof(ViewportsTest), serverConnectorFactory, logHandler);
            Eyes eyes = new Eyes(runner);

            Configuration sconf = new Configuration();

            sconf.SetBatch(TestDataProvider.BatchInfo);
            sconf.SetTestName("Viewport Size Test");
            sconf.SetAppName("Visual Grid Viewports Test");
            sconf.SetHideScrollbars(true);
            sconf.SetStitchMode(StitchModes.CSS);
            sconf.SetForceFullPageScreenshot(true);
            sconf.SetMatchLevel(MatchLevel.Strict);
            int numOfBrowsers = 0;

            foreach (BrowserType b in Enum.GetValues(typeof(BrowserType)))
            {
#pragma warning disable CS0618 // Type or member is obsolete
                if (b == BrowserType.EDGE)
                {
                    continue;
                }
#pragma warning restore CS0618 // Type or member is obsolete
                sconf.AddBrowser(700, 500, b);
                sconf.AddBrowser(800, 600, b);
                numOfBrowsers++;
            }
            eyes.SetConfiguration(sconf);

            ChromeDriver driver = SeleniumUtils.CreateChromeDriver();
            webdriverProvider.SetDriver(driver);
            try
            {
                eyes.Open(driver);
                driver.Url = "data:text/html,<html><body><h1>Hello, world!</h1></body></html>";
                eyes.Check("Test Viewport", Target.Window().Fully());
            }
            finally
            {
                driver.Quit();
            }
            TestResultsSummary      allResults      = runner.GetAllTestResults(false);
            MockServerConnector     serverConnector = (MockServerConnector)runner.ServerConnector;
            HashSet <RenderRequest> requests        = new HashSet <RenderRequest>();
            foreach (string requestJson in serverConnector.RenderRequests)
            {
                RenderRequest[] reqs = Newtonsoft.Json.JsonConvert.DeserializeObject <RenderRequest[]>(requestJson);
                foreach (RenderRequest req in reqs)
                {
                    requests.Add(req);
                }
            }
            int browserCount = sconf.GetBrowsersInfo().Count;
            Assert.AreEqual(browserCount, numOfBrowsers * 2);
            Assert.AreEqual(browserCount, requests.Count);
        }
Beispiel #2
0
        //[TestCase(true), TestCase(false)]
        public void HelloWorldTest(bool useVisualGrid)
        {
            IWebDriver webDriver = SeleniumUtils.CreateChromeDriver();

            webDriver.Url = "https://applitools.com/helloworld";

            EyesRunner runner = useVisualGrid ? (EyesRunner) new VisualGridRunner(10) : new ClassicRunner();

            runner.SetLogHandler(TestUtils.InitLogHandler());
            Eyes eyes = new Eyes(runner);

            Configuration sconf = eyes.GetConfiguration();

            string suffix = useVisualGrid ? "_VG" : "";

            // Set test name
            sconf.SetTestName("Hello World Demo" + suffix);

            // Set app name
            sconf.SetAppName("Hello World Demo");

            // Add browsers
            sconf.AddBrowser(800, 600, BrowserType.CHROME);
            sconf.AddBrowser(700, 500, BrowserType.FIREFOX);
            sconf.AddBrowser(1200, 800, BrowserType.IE_10);
            sconf.AddBrowser(1200, 800, BrowserType.IE_11);
            sconf.AddBrowser(1600, 1200, BrowserType.EDGE);

            // Set the configuration object to eyes
            eyes.SetConfiguration(sconf);

            try
            {
                // Call Open on eyes to initialize a test session
                eyes.Open(webDriver);

                // Add 2 checks
                eyes.Check(Target.Window().WithName("Step 1 - Viewport").Ignore(By.CssSelector(".primary")));
                eyes.Check(Target.Window().Fully().WithName("Step 1 - Full Page")
                           .Floating(By.CssSelector(".primary"), 10, 20, 30, 40)
                           .Floating(By.TagName("button"), 1, 2, 3, 4));

                webDriver.FindElement(By.TagName("button")).Click();

                // Add 2 checks
                eyes.Check(Target.Window().WithName("Step 2 - Viewport"));
                eyes.Check(Target.Window().Fully().WithName("Step 2 - Full Page"));

                // Close eyes and collect results
                eyes.Close();
            }
            finally
            {
                eyes.Abort();
                webDriver.Quit();
            }
        }
Beispiel #3
0
        private void RunVisualGridDemo()
        {
            // Create a runner with concurrency of 10
            VisualGridRunner runner = new VisualGridRunner(10);

            // Create a file logger with default file ('eyes.log', verbose, in current directory).
            FileLogHandler logHandler = new FileLogHandler();

            // Set the log handler.
            runner.SetLogHandler(logHandler);

            // Create Eyes object with the runner, meaning it'll be a Visual Grid eyes.
            Eyes eyes = new Eyes(runner);

            // Create Selenium Configuration.
            Configuration sconf = new Configuration();

            // Set app name
            sconf.AppName = "Visual Grid Demo App";

            // Set test name
            sconf.TestName = "Visual Grid Demo Test";

            // Add browsers
            sconf.AddBrowser(800, 600, Configuration.BrowserType.CHROME);
            sconf.AddBrowser(700, 500, Configuration.BrowserType.FIREFOX);
            sconf.AddBrowser(1200, 800, Configuration.BrowserType.IE10);
            sconf.AddBrowser(1200, 800, Configuration.BrowserType.IE11);
            sconf.AddBrowser(1600, 1200, Configuration.BrowserType.EDGE);

            // Add iPhone 4 device emulation
            EmulationInfo iphone4 = new EmulationInfo(EmulationInfo.DeviceNameEnum.iPhone_4, ScreenOrientation.Portrait);

            sconf.AddDeviceEmulation(iphone4);

            // Add custom mobile device emulation
            EmulationDevice customMobile = new EmulationDevice(width: 1024, height: 768, deviceScaleFactor: 2);

            sconf.AddDeviceEmulation(customMobile);

            sconf.AddDeviceEmulation(EmulationInfo.DeviceNameEnum.iPhone_5SE, ScreenOrientation.Landscape);
            sconf.AddDeviceEmulation(EmulationInfo.DeviceNameEnum.Galaxy_S5);

            sconf.AddDeviceEmulation(800, 640);

            RunTest(eyes, sconf);

            TestResultSummary allTestResults = runner.GetAllTestResults();
        }
        public void TestResetContent()
        {
            Configuration config = new Configuration();

            config.AddBrowser(new IosDeviceInfo(IosDeviceName.iPhone_7));
            ConfigurationProvider configurationProvider = new ConfigurationProvider(config);
            VisualGridRunner      runner = new VisualGridRunner(new RunnerOptions().TestConcurrency(3));
            VisualGridEyes        eyes   = new VisualGridEyes(configurationProvider, runner);

            eyes.SetLogHandler(TestUtils.InitLogHandler());

            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

            driver.Url = "http://applitools.github.io/demo";
            try
            {
                eyes.Open(driver, "Eyes SDK", "UFG Runner Concurrency", new Size(800, 800));
                eyes.Check(Target.Window().Fully());
                eyes.CloseAsync(true);
            }
            finally
            {
                eyes.AbortAsync();
                driver.Quit();
                runner.GetAllTestResults(false);
            }

            foreach (ResourceFuture resourceFuture in ((IVisualGridRunner)runner).CachedResources.Values)
            {
                RGridResource resource = resourceFuture.GetResource();
                Assert.IsNotNull(resource);
                Assert.IsNull(resource.Content);
            }
        }
Beispiel #5
0
        public void TestTimeout2()
        {
            EyesSeleniumUtils.CAPTURE_TIMEOUT = TimeSpan.FromTicks(1);
            IWebDriver       driver     = SeleniumUtils.CreateChromeDriver();
            ILogHandler      logHandler = TestUtils.InitLogHandler();
            VisualGridRunner runner     = new VisualGridRunner(10, logHandler);

            try
            {
                Eyes eyes = new Eyes(runner);
                driver.Url = "https://applitools.com/helloworld";
                eyes.Batch = TestDataProvider.BatchInfo;

                Configuration configuration = eyes.GetConfiguration();
                configuration.SetAppName("Test Timeouts").SetTestName("Test Timeouts").SetBatch(TestDataProvider.BatchInfo);
                configuration.AddBrowser(800, 600, BrowserType.CHROME);
                configuration.AddDeviceEmulation(DeviceName.Laptop_with_HiDPI_screen);
                eyes.SetConfiguration(configuration);
                eyes.Open(driver);
                Assert.That(() =>
                {
                    eyes.Check(Target.Window().WithName("Test"));
                    eyes.Close();
                    runner.GetAllTestResults();
                }, Throws.Exception.With.InstanceOf <EyesException>().With.InnerException.With.InstanceOf <EyesException>().With.Property("Message").EqualTo("DOM capture timeout."));
            }
            finally
            {
                driver.Quit();
                runner.StopServiceRunner();
            }
        }
        public void TestParallelStepsLimitOfTest()
        {
            bool isOnlyOneRender     = true;
            int  runningRendersCount = 0;

            VisualGridRunner runner = new VisualGridRunner();
            Configuration    config = new Configuration();

            config.AddBrowser(new IosDeviceInfo(IosDeviceName.iPhone_7));
            ConfigurationProvider configurationProvider = new ConfigurationProvider(config);

            VisualGridEyes eyes = new VisualGridEyes(configurationProvider, runner);

            eyes.SetLogHandler(TestUtils.InitLogHandler());
            eyes.EyesConnectorFactory = new MockEyesConnectorFactory();

            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

            try
            {
                driver.Url = "http://applitools.github.io/demo";
                eyes.Open(driver, "Eyes SDK", "UFG Server Concurrency", new RectangleSize(800, 800));
                MockEyesConnector mockEyesConnector = (MockEyesConnector)eyes.eyesConnector_;

                mockEyesConnector.BeforeRender += (renderRequests) =>
                {
                    int runningRendersCountBeforeInc = runningRendersCount;
                    Interlocked.Increment(ref runningRendersCount);
                    if (runningRendersCountBeforeInc >= RunningTest.PARALLEL_STEPS_LIMIT)
                    {
                        isOnlyOneRender = false;
                    }

                    Thread.Sleep(1000);
                    if (renderRequests.Length != 1)
                    {
                        isOnlyOneRender = false;
                    }
                };

                mockEyesConnector.AfterRender += (results, renderRequests) =>
                {
                    Interlocked.Decrement(ref runningRendersCount);
                };

                for (int i = 0; i < 10; i++)
                {
                    eyes.Check(Target.Window().Fully());
                }
                eyes.CloseAsync(false);
            }
            finally
            {
                eyes.AbortAsync();
                driver.Quit();
                runner.GetAllTestResults(false);
            }

            Assert.IsTrue(isOnlyOneRender);
        }
Beispiel #7
0
        public void TestRenderSpecialCharacters()
        {
            VisualGridRunner runner = new VisualGridRunner(30);
            Eyes             eyes   = new Eyes(runner);

            eyes.SetLogHandler(TestUtils.InitLogHandler());

            Configuration sconf = new Configuration();

            sconf.SetTestName("Special Characters");
            sconf.SetAppName("Special Characters Test");

            sconf.AddBrowser(800, 600, BrowserType.CHROME);
            sconf.SetBatch(TestDataProvider.BatchInfo);

            eyes.SetConfiguration(sconf);
            ChromeDriver driver = SeleniumUtils.CreateChromeDriver();

            eyes.Open(driver);
            driver.Url = "https://applitools.github.io/demo/TestPages/SpecialCharacters/index.html";
            eyes.Check("Test Special Characters", Target.Window().Fully());
            driver.Quit();
            eyes.Close();
            TestResultsSummary allResults = runner.GetAllTestResults();
        }
        public void BeforeTestSuite()
        {
            // 1. Create the runner that manages multiple tests
            if (useVisualGrid_)
            {
                runner = new VisualGridRunner(concurrentSessions);
            }
            else
            {
                runner = new ClassicRunner();
            }
            // continued below....
            // 2. Create a configuration object, we will use this when setting up each test
            suiteConfig = new Configuration();

            // 3. Set the various configuration values
            suiteConfig
            // 4. Add Visual Grid browser configurations
            .AddBrowser(900, 600, BrowserType.CHROME)
            .AddBrowser(1024, 786, BrowserType.CHROME)
            .AddBrowser(900, 600, BrowserType.FIREFOX)
            .AddBrowser(900, 600, BrowserType.IE_10)
            .AddBrowser(900, 600, BrowserType.IE_11)
            .AddBrowser(900, 600, BrowserType.EDGE)
            .AddDeviceEmulation(DeviceName.iPhone_4, Applitools.VisualGrid.ScreenOrientation.Portrait)
            .AddDeviceEmulation(DeviceName.Galaxy_S5, Applitools.VisualGrid.ScreenOrientation.Landscape)

            // 5. set up default Eyes configuration values
            .SetBatch(new BatchInfo(batchName))
            .SetAppName(appName)
            .SetViewportSize(new Applitools.Utils.Geometry.RectangleSize(viewPortWidth, viewPortHeight));
        }
        public void BeforeSuite()
        {
            visualGridRunner = new VisualGridRunner(concurrentSessions);
            visualGridRunner.SetLogHandler(TestUtils.InitLogHandler(nameof(TestEkbVg), verbose: false));
            visualGridRunner.Logger.Log("enter");
            batchInfo   = new BatchInfo("test EKB VG");
            suiteConfig = new Configuration();
            suiteConfig.AddBrowser(viewPortWidth, viewPortHeight, BrowserType.CHROME)
            .SetHideScrollbars(true)
            .SetHideCaret(true)
            .SetWaitBeforeScreenshots(10000)
            .SetAppName(appName)
            .SetViewportSize(new RectangleSize(viewPortWidth, viewPortHeight))
            .SetMatchTimeout(TimeSpan.FromSeconds(6))
            .SetBatch(batchInfo);

            visualGridRunner.Logger.Log("creating {0} chrome drivers", webDrivers.BoundedCapacity);

            for (int i = 0; i < webDrivers.BoundedCapacity; ++i)
            {
                webDrivers.Add(SeleniumUtils.CreateChromeDriver());
            }

            visualGridRunner.Logger.Log("createdg {0} chrome drivers", webDrivers.Count);
        }
        public void TestRetryWhenServerConcurrencyLimitReached()
        {
            Configuration config = new Configuration();

            config.AddBrowser(new IosDeviceInfo(IosDeviceName.iPhone_7));

            ConfigurationProvider configurationProvider = new ConfigurationProvider(config);
            VisualGridRunner      runner = new VisualGridRunner(new RunnerOptions().TestConcurrency(3));
            VisualGridEyes        eyes   = new VisualGridEyes(configurationProvider, runner);

            eyes.SetLogHandler(TestUtils.InitLogHandler());

            int  counter            = 0;
            bool wasConcurrencyFull = false;

            eyes.EyesConnectorFactory = new MockEyesConnectorFactory()
            {
                Events = new Events()
                {
                    BeforeStartSession = () =>
                    {
                        if (Interlocked.Increment(ref counter) < 4)
                        {
                            RunningSession newSession = new RunningSession();
                            newSession.ConcurrencyFull = true;
                            return(newSession);
                        }
                        return(null);
                    }
                }
            };

            eyes.AfterServerConcurrencyLimitReachedQueried += (concurrecnyReached) =>
            {
                if (concurrecnyReached)
                {
                    wasConcurrencyFull = true;
                }
            };

            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

            driver.Url = "http://applitools.github.io/demo";
            try
            {
                eyes.Open(driver, "Eyes SDK", "UFG Runner Concurrency", new Size(800, 800));
                eyes.Check(Target.Window().Fully());
                eyes.CloseAsync(true);
            }
            finally
            {
                eyes.AbortAsync();
                driver.Quit();
                runner.GetAllTestResults(false);
            }

            Assert.IsTrue(wasConcurrencyFull);
            Assert.IsFalse(((IVisualGridEyes)eyes).IsServerConcurrencyLimitReached());
            Assert.AreEqual(4, counter);
        }
Beispiel #11
0
        private static void ConfigureSingleBrowser(Eyes eyes)
        {
            Configuration config = eyes.GetConfiguration();

            config.AddBrowser(1200, 800, BrowserType.CHROME);
            eyes.SetConfiguration(config);
        }
Beispiel #12
0
        public void TestSpecialRendering(string url, string testName)
        {
            string           logsPath   = TestUtils.InitLogPath();
            ILogHandler      logHandler = TestUtils.InitLogHandler(logPath: logsPath);
            VisualGridRunner runner     = new VisualGridRunner(30, logHandler);

            runner.DebugResourceWriter = new FileDebugResourceWriter(logsPath);

            Eyes eyes = new Eyes(runner);

            Configuration sconf = new Configuration();

            sconf.SetTestName(testName);
            sconf.SetAppName("Visual Grid Render Test");
            sconf.SetBatch(TestDataProvider.BatchInfo);

            sconf.AddDeviceEmulation(DeviceName.Galaxy_S5);
            sconf.AddBrowser(1200, 800, BrowserType.CHROME);
            sconf.AddBrowser(1200, 800, BrowserType.FIREFOX);

            // Edge doesn't support Shadow-DOM - returns an empty image.
            //sconf.AddBrowser(1200, 800, BrowserType.EDGE);

            // Internet Explorer doesn't support Shadow-DOM - fails to render and throws an error.
            //sconf.AddBrowser(1200, 800, BrowserType.IE_11);
            //sconf.AddBrowser(1200, 800, BrowserType.IE_10);

            eyes.SetConfiguration(sconf);
            ChromeDriver driver = SeleniumUtils.CreateChromeDriver();

            try
            {
                eyes.Open(driver);
                driver.Url = url;
                Thread.Sleep(500);
                eyes.Check(testName, Target.Window().Fully());
                eyes.Close(false);
                TestResultsSummary allResults = runner.GetAllTestResults(false);
            }
            finally
            {
                driver.Quit();
                eyes.AbortIfNotClosed();
                runner.StopServiceRunner();
            }
        }
        public void TestDefaultRenderingOfMultipleTargets()
        {
            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

            driver.Url = "https://applitools.com/helloworld";
            VisualGridRunner runner = new VisualGridRunner(10);
            Eyes             eyes   = new Eyes(runner);
            Configuration    config = eyes.GetConfiguration();

            config.AddBrowser(800, 600, BrowserType.CHROME);
            config.AddBrowser(800, 600, BrowserType.FIREFOX);
            config.AddBrowser(1200, 800, BrowserType.CHROME);
            config.AddBrowser(1200, 800, BrowserType.FIREFOX);
            config.SetAppName(nameof(TestDefaultRendering)).SetTestName(nameof(TestDefaultRenderingOfMultipleTargets));
            eyes.SetConfiguration(config);
            try
            {
                eyes.Open(driver);
                eyes.Check(Target.Window());
                eyes.Close();
            }
            finally
            {
                eyes.Abort();
                driver.Quit();
            }
            TestResultsSummary allTestResults = runner.GetAllTestResults();
            string             batchId        = null;
            string             batchName      = null;

            foreach (TestResultContainer trc in allTestResults)
            {
                if (batchId == null)
                {
                    batchId = trc.TestResults.BatchId;
                }
                if (batchName == null)
                {
                    batchName = trc.TestResults.BatchName;
                }
                Assert.AreEqual(batchId, trc.TestResults.BatchId);
                Assert.AreEqual(batchName, trc.TestResults.BatchName);
            }
        }
Beispiel #14
0
        private static void ConfigureMultipleBrowsers(Eyes eyes)
        {
            Configuration config = eyes.GetConfiguration();

            config.AddDeviceEmulation(DeviceName.Galaxy_S5);
            foreach (BrowserType b in Enum.GetValues(typeof(BrowserType)))
            {
                //config.AddBrowser(700, 500, b);
                config.AddBrowser(800, 600, b);
                //config.AddBrowser(900, 700, b);
                config.AddBrowser(1200, 800, b);
                config.AddBrowser(1600, 1200, b);
            }

            //config.AddBrowser(700, 500,   BrowserType.CHROME);
            //config.AddBrowser(900, 700,   BrowserType.CHROME);
            //config.AddBrowser(1200, 800,  BrowserType.CHROME);
            //config.AddBrowser(1600, 1200, BrowserType.CHROME);

            //config.AddBrowser(700, 500,   BrowserType.FIREFOX);
            //config.AddBrowser(900, 700,   BrowserType.FIREFOX);
            //config.AddBrowser(1200, 800,  BrowserType.FIREFOX);
            //config.AddBrowser(1600, 1200, BrowserType.FIREFOX);

            //config.AddBrowser(700, 500,   BrowserType.IE_10);
            //config.AddBrowser(900, 700,   BrowserType.IE_10);
            //config.AddBrowser(1200, 800,  BrowserType.IE_10);
            //config.AddBrowser(1600, 1200, BrowserType.IE_10);

            //config.AddBrowser(700, 500,   BrowserType.IE_11);
            //config.AddBrowser(900, 700,   BrowserType.IE_11);
            //config.AddBrowser(1200, 800,  BrowserType.IE_11);
            //config.AddBrowser(1600, 1200, BrowserType.IE_11);

            //config.AddBrowser(700, 500,   BrowserType.EDGE);
            //config.AddBrowser(900, 700,   BrowserType.EDGE);
            //config.AddBrowser(1200, 800,  BrowserType.EDGE);
            //config.AddBrowser(1600, 1200, BrowserType.EDGE);
            eyes.SetConfiguration(config);
        }
Beispiel #15
0
        //[Test]
        public void TestUFGVisualViewport_UnitTest()
        {
            JsonSerializer serializer = JsonUtils.CreateSerializer();
            IWebDriver     driver     = SeleniumUtils.CreateChromeDriver();
            EyesRunner     runner     = new VisualGridRunner(10);
            Eyes           eyes       = new Eyes(runner);

            TestUtils.SetupLogging(eyes);
            eyes.visualGridEyes_.EyesConnectorFactory = new Mock.MockEyesConnectorFactory();
            Configuration config        = eyes.GetConfiguration();
            IosDeviceInfo iosDeviceInfo = new IosDeviceInfo(IosDeviceName.iPhone_11_Pro);

            config.AddBrowser(iosDeviceInfo);
            eyes.SetConfiguration(config);
            try
            {
                eyes.Open(driver, "Eyes Selenium SDK", "Eyes Selenium SDK - UFG Visual Viewport Test");
                Mock.MockEyesConnector   mockEyesConnector   = (Mock.MockEyesConnector)eyes.visualGridEyes_.eyesConnector_;
                Mock.MockServerConnector mockServerConnector = new Mock.MockServerConnector(eyes.Logger, new Uri(eyes.ServerUrl));
                EyesConnector            eyesConnector       = new EyesConnector(eyes.Logger, new RenderBrowserInfo(iosDeviceInfo), config)
                {
                    runningSession_ = new RunningSession(),
                    ServerConnector = mockServerConnector
                };
                mockEyesConnector.WrappedConnector = eyesConnector;

                string inputJson = CommonUtils.ReadResourceFile("Test.Eyes.Selenium.DotNet.Resources.Misc.TestUFGVisualViewport_Input.json");
                RenderStatusResults renderStatusResults = serializer.Deserialize <RenderStatusResults>(inputJson);
                mockEyesConnector.SetRenderStatusResultsList(renderStatusResults);

                driver.Url = "https://applitools.github.io/demo/TestPages/DynamicResolution/desktop.html";
                eyes.Check(Target.Window().Fully());
                eyes.Close();

                runner.GetAllTestResults();

                Assert.AreEqual(1, mockServerConnector.MatchWindowCalls.Count);
                MatchWindowData matchWindowData = mockServerConnector.MatchWindowCalls[0];
                AppOutput       appOutput       = matchWindowData.AppOutput;
                Assert.AreEqual(980, appOutput.Viewport.Width);
                Assert.AreEqual(1659, appOutput.Viewport.Height);
                Assert.IsNotNull(mockEyesConnector.DeviceSize);
                Assert.AreEqual(375, mockEyesConnector.DeviceSize.Width);
                Assert.AreEqual(812, mockEyesConnector.DeviceSize.Height);
            }
            finally
            {
                eyes.AbortIfNotClosed();
                driver.Quit();
            }
        }
 private void Editor_Closing(object sender, CancelEventArgs e)
 {
     ((Window)sender).Closing -= Editor_Closing;
     if (!(((Window)sender).DataContext is BrowserViewModel browser))
     {
         return;
     }
     if (string.IsNullOrEmpty(browser.Model.Name) || string.IsNullOrEmpty(browser.Model.Command))
     {
         return;
     }
     Choices.Add(browser);
     Configuration.AddBrowser(browser.Model);
 }
        public void Test_VGTestsCount_2()
        {
            TestObjects testObjects = InitEyes_();

            try
            {
                Configuration conf = new Configuration();
                conf.SetBatch(TestDataProvider.BatchInfo);
                conf.AddBrowser(new DesktopBrowserInfo(900, 600));
                conf.AddBrowser(new DesktopBrowserInfo(1024, 768));
                testObjects.Eyes.SetConfiguration(conf);
                testObjects.Eyes.Open(testObjects.WebDriver, "Test Count", "Test_VGTestsCount_2");
                testObjects.Eyes.Check("Test", Target.Window());
                testObjects.Eyes.Close();
                TestResultsSummary resultsSummary = testObjects.Runner.GetAllTestResults();
                Assert.AreEqual(2, resultsSummary?.Count);
            }
            finally
            {
                testObjects.WebDriver.Quit();
                testObjects.Eyes.Abort();
            }
        }
        protected Eyes InitEyes(IWebDriver webDriver, string testedUrl)
        {
            Eyes eyes = new Eyes(renderingManager_);

            eyes.Batch = batchInfo_;
            Logger logger = eyes.Logger;

            logger.Log("creating WebDriver: " + testedUrl);
            Configuration renderingConfiguration = new Configuration();

            renderingConfiguration.SetTestName("Top Sites - " + testedUrl);
            renderingConfiguration.SetAppName("Top Sites");
            string environment = "";

            renderingConfiguration.AddBrowser(800, 600, BrowserType.CHROME, environment);
            renderingConfiguration.AddBrowser(700, 500, BrowserType.FIREFOX, environment);
            renderingConfiguration.AddBrowser(1200, 800, BrowserType.IE_11, environment);
            renderingConfiguration.AddBrowser(1600, 1200, BrowserType.EDGE, environment);
            logger.Log("created configurations for url " + testedUrl);
            eyes.SetConfiguration(renderingConfiguration);
            eyes.Open(webDriver);
            return(eyes);
        }
Beispiel #19
0
        public void Trello_1544()
        {
            //EyesRunner runner = new VisualGridRunner(10);
            EyesRunner runner = new ClassicRunner();

            Eyes eyes = new Eyes(runner);

            Configuration configuration = eyes.GetConfiguration();

            configuration.AddBrowser(800, 600, BrowserType.CHROME);
            configuration.AddBrowser(1600, 1200, BrowserType.CHROME);
            eyes.SetConfiguration(configuration);

            eyes.SetLogHandler(new NunitLogHandler(true));
            eyes.MatchTimeout = TimeSpan.FromSeconds(0);
            IWebDriver driver = new ChromeDriver();

            try
            {
                eyes.Open(driver, "Trello 1544 PNC", "Intermittent Coded Regions", new Size(800, 600));
                driver.Url = "https://www.pnc.com/en/personal-banking.html";

                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
                wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("#container > div.hero-login-wrapper")));

                eyes.Check(Target.Window().Fully()
                           .Layout(By.CssSelector("#container > div.hero-login-wrapper"))
                           .Layout(By.CssSelector("#main-header > div.header-wrapper"))
                           );
                eyes.Close(false);
            }
            finally
            {
                driver.Quit();
                runner.GetAllTestResults();
            }
        }
Beispiel #20
0
        public void LocalSetUp()
        {
            driver_     = SeleniumUtils.CreateChromeDriver();
            driver_.Url = "data:text/html,<p>Test</p>";
            runner_     = useVisualGrid_ ? (EyesRunner) new VisualGridRunner(10) : new ClassicRunner();
            eyes_       = new Eyes(runner_);
            eyes_.Batch = TestDataProvider.BatchInfo;
            string testName = useVisualGrid_ ? "Test Abort_VG" : "Test Abort";

            Configuration config = eyes_.GetConfiguration();

            config.AddBrowser(800, 600, BrowserType.CHROME);
            eyes_.SetConfiguration(config);

            eyes_.Open(driver_, testName, testName, new Size(1200, 800));
        }
        public void TestOpenBeforeRender()
        {
            VisualGridRunner runner = new VisualGridRunner(10);
            Eyes             eyes   = new Eyes(runner);

            eyes.SetLogHandler(TestUtils.InitLogHandler());
            eyes.visualGridEyes_.EyesConnectorFactory = new MockEyesConnectorFactory();

            Configuration config = eyes.GetConfiguration();

            config.AddBrowser(new IosDeviceInfo(IosDeviceName.iPhone_7));
            eyes.SetConfiguration(config);

            object errorMessageLocker = new object();
            string errorMessage       = null;

            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

            driver.Url = "http://applitools.github.io/demo";
            try
            {
                eyes.Open(driver, "Mock app", "Mock Test");
                MockEyesConnector mockEyesConnector = (MockEyesConnector)eyes.visualGridEyes_.eyesConnector_;

                mockEyesConnector.BeforeRender += (renderRequests) =>
                {
                    IVisualGridEyes eyes = runner.allEyes_.First();
                    if (!eyes.GetAllRunningTests().First().IsTestOpen)
                    {
                        lock (errorMessageLocker)
                        {
                            errorMessage = "Render called before open";
                        }
                    }
                };
                eyes.CheckWindow();
                eyes.CloseAsync();
            }
            finally
            {
                eyes.AbortAsync();
                driver.Quit();
                runner.GetAllTestResults(false);
            }

            Assert.IsNull(errorMessage);
        }
        public void TestVisualGridSkipList()
        {
            VisualGridRunner runner = new VisualGridRunner(10);
            Eyes             eyes   = new Eyes(runner);

            TestUtils.SetupLogging(eyes);
            eyes.visualGridEyes_.EyesConnectorFactory = new Mock.MockEyesConnectorFactory();

            Configuration config = eyes.GetConfiguration();

            config.AddBrowser(1050, 600, BrowserType.CHROME);
            config.SetBatch(TestDataProvider.BatchInfo);
            eyes.SetConfiguration(config);

            MockEyesConnector mockEyesConnector;

            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

            driver.Url = "https://applitools.github.io/demo/DomSnapshot/test-iframe.html";
            try
            {
                mockEyesConnector = OpenEyesAndGetConnector_(eyes, config, driver);

                eyes.Check(Target.Window());
                string[] expectedUrls = new string[] {
                    "https://applitools.github.io/demo/DomSnapshot/test.css",
                    "https://applitools.github.io/demo/DomSnapshot/smurfs.jpg",
                    "https://applitools.github.io/blabla",
                    "https://applitools.github.io/demo/DomSnapshot/iframes/inner/smurfs.jpg",
                    "https://applitools.github.io/demo/DomSnapshot/test.html",
                    "https://applitools.github.io/demo/DomSnapshot/iframes/inner/test.html",
                    "https://applitools.github.io/demo/DomSnapshot/iframes/frame.html"
                };
                CollectionAssert.AreEquivalent(expectedUrls, runner.CachedBlobsURLs.Keys);
                eyes.Check(Target.Window());
                eyes.Close();

                runner.GetAllTestResults();
            }
            finally
            {
                eyes.AbortIfNotClosed();
                driver.Close();
            }
        }
Beispiel #23
0
        public void TestUFGVisualViewport()
        {
            JsonSerializer serializer = JsonUtils.CreateSerializer();
            IWebDriver     driver     = SeleniumUtils.CreateChromeDriver();
            EyesRunner     runner     = new VisualGridRunner(10);
            Eyes           eyes       = new Eyes(runner);

            TestUtils.SetupLogging(eyes);
            Configuration config        = eyes.GetConfiguration();
            IosDeviceInfo iosDeviceInfo = new IosDeviceInfo(IosDeviceName.iPhone_11_Pro);

            config.AddBrowser(iosDeviceInfo);
            eyes.SetConfiguration(config);
            try
            {
                eyes.Open(driver, "Eyes Selenium SDK", "Eyes Selenium SDK - UFG Visual Viewport Test");

                string inputJson = CommonUtils.ReadResourceFile("Test.Eyes.Selenium.DotNet.Resources.Misc.TestUFGVisualViewport_Input.json");
                RenderStatusResults renderStatusResults = serializer.Deserialize <RenderStatusResults>(inputJson);

                driver.Url = "https://applitools.github.io/demo/TestPages/DynamicResolution/desktop.html";
                eyes.Check(Target.Window().Fully());
                eyes.Close(false);

                TestResultsSummary resultsSummary = runner.GetAllTestResults(false);
                Assert.AreEqual(1, resultsSummary.Count);
                TestResults    results        = resultsSummary[0].TestResults;
                SessionResults sessionResults = TestUtils.GetSessionResults(eyes.ApiKey, results);

                Assert.AreEqual(1, sessionResults.ActualAppOutput.Length);
                ActualAppOutput appOutput = sessionResults.ActualAppOutput[0];
                Assert.AreEqual(980, appOutput.Image.Viewport.Width);
                Assert.AreEqual(1659, appOutput.Image.Viewport.Height);

                Assert.AreEqual(375, sessionResults.Env.DisplaySize.Width);
                Assert.AreEqual(812, sessionResults.Env.DisplaySize.Height);
            }
            finally
            {
                eyes.AbortIfNotClosed();
                driver.Quit();
            }
        }
Beispiel #24
0
        public void TestCloseAsync()
        {
            EyesRunner runner = new VisualGridRunner(10);
            Eyes       eyes   = new Eyes(runner);
            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

            TestUtils.SetupLogging(eyes);
            driver.Url = "https://applitools.com/helloworld";
            try
            {
                Configuration config = new Configuration();
                config.SetAppName("Visual Grid Tests").SetTestName("Test CloseAsync").SetBatch(TestDataProvider.BatchInfo);
                foreach (BrowserType b in Enum.GetValues(typeof(BrowserType)))
                {
                    if (b == BrowserType.EDGE || b == BrowserType.EDGE_LEGACY)
                    {
                        continue;
                    }
                    config.AddBrowser(800, 600, b);
                }
                eyes.SetConfiguration(config);
                var combinations = config.GetBrowsersInfo();
                Assert.Greater(combinations.Count, 1);
                eyes.Open(driver);
                eyes.CheckWindow();
                driver.Quit();
                driver = null;
                ICollection <Task <TestResultContainer> > closeTasks = eyes.CloseAsync_();
                Assert.AreEqual(combinations.Count, closeTasks.Count);
                runner.GetAllTestResults();
            }
            finally
            {
                if (driver != null)
                {
                    driver.Quit();
                }
                eyes.Abort();
            }
        }
        public void TestRunnerConcurrency()
        {
            Configuration config = new Configuration();

            config.AddBrowser(new IosDeviceInfo(IosDeviceName.iPhone_7));
            config.AddDeviceEmulation(DeviceName.Galaxy_S5, ScreenOrientation.Landscape);
            config.AddBrowser(new DesktopBrowserInfo(800, 800, BrowserType.CHROME));
            config.AddBrowser(new DesktopBrowserInfo(800, 800, BrowserType.FIREFOX));
            config.AddBrowser(new DesktopBrowserInfo(800, 800, BrowserType.SAFARI));

            ConfigurationProvider configurationProvider = new ConfigurationProvider(config);
            VisualGridRunner      runner = new VisualGridRunner(new RunnerOptions().TestConcurrency(3));
            VisualGridEyes        eyes   = new VisualGridEyes(configurationProvider, runner);

            eyes.SetLogHandler(TestUtils.InitLogHandler());

            int  currentlyOpenTests = 0;
            bool isFail             = false;

            eyes.EyesConnectorFactory = new MockEyesConnectorFactory()
            {
                Events = new Events()
                {
                    BeforeStartSession = () =>
                    {
                        if (Interlocked.Increment(ref currentlyOpenTests) > 3)
                        {
                            isFail = true;
                        }
                        Thread.Sleep(3000);
                        if (currentlyOpenTests > 3)
                        {
                            isFail = true;
                        }
                        return(null);
                    },
                    AfterEndSession = () =>
                    {
                        Interlocked.Decrement(ref currentlyOpenTests);
                    }
                }
            };

            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

            driver.Url = "http://applitools.github.io/demo";
            try
            {
                eyes.Open(driver, "Eyes SDK", "UFG Runner Concurrency", new Size(800, 800));
                eyes.Check(Target.Window().Fully());
                eyes.CloseAsync(true);
            }
            finally
            {
                eyes.AbortAsync();
                driver.Quit();
                runner.GetAllTestResults(false);
            }

            Assert.IsFalse(isFail, "Number of open tests was higher than the concurrency limit");
        }
Beispiel #26
0
        public void TestIosDeviceReportedResolutionOnFailure()
        {
            ILogHandler logHandler = TestUtils.InitLogHandler();
            EyesRunner  runner     = new VisualGridRunner(10, logHandler);
            Eyes        eyes       = new Eyes(runner);

            Configuration config = eyes.GetConfiguration();

            config.AddBrowser(new DesktopBrowserInfo(new RectangleSize(700, 460), BrowserType.CHROME));
            config.AddDeviceEmulation(DeviceName.Galaxy_S3);
            config.AddBrowser(new IosDeviceInfo(IosDeviceName.iPhone_11_Pro));
            config.AddBrowser(new IosDeviceInfo(IosDeviceName.iPhone_XR));
            config.SetBatch(TestDataProvider.BatchInfo);
            config.SetAppName("Visual Grid DotNet Tests");
            config.SetTestName("UFG Mobile Device No Result");
            eyes.SetConfiguration(config);

            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

            driver.Url = "https://demo.applitools.com";
            try
            {
                eyes.Open(driver);
                eyes.Check(Target.Window());
                eyes.CloseAsync();
            }
            finally
            {
                driver.Quit();
                eyes.AbortAsync();
            }

            TestResultsSummary allTestResults = runner.GetAllTestResults(false);

            Assert.AreEqual(4, allTestResults.GetAllResults().Length);

            // Set results in array
            TestResults[] testResults = new TestResults[4];
            foreach (TestResultContainer resultsContainer in allTestResults)
            {
                RenderBrowserInfo browserInfo = resultsContainer.BrowserInfo;
                TestResults       results     = resultsContainer.TestResults;
                if (browserInfo.IosDeviceInfo == null && browserInfo.EmulationInfo == null)
                {
                    testResults[0] = results;
                    continue;
                }

                if (browserInfo.EmulationInfo != null)
                {
                    testResults[1] = results;
                    continue;
                }

                IosDeviceName deviceName = browserInfo.IosDeviceInfo.DeviceName;
                if (deviceName == IosDeviceName.iPhone_11_Pro)
                {
                    testResults[2] = results;
                    continue;
                }

                if (deviceName == IosDeviceName.iPhone_XR)
                {
                    testResults[3] = results;
                    continue;
                }

                Assert.Fail();
            }

            Assert.AreEqual(new RectangleSize(700, 460), testResults[0].HostDisplaySize);
            Assert.AreEqual(new RectangleSize(360, 640), testResults[1].HostDisplaySize);
            Assert.AreEqual(new RectangleSize(375, 812), testResults[2].HostDisplaySize);
            Assert.AreEqual(new RectangleSize(414, 896), testResults[3].HostDisplaySize);
        }
Beispiel #27
0
        public void TestIosDeviceReportedResolutionOnFailure()
        {
            EyesRunner runner = new VisualGridRunner(10);
            Eyes       eyes   = new Eyes(runner);

            TestUtils.SetupLogging(eyes);
            eyes.visualGridEyes_.EyesConnectorFactory = new LocalEyesConnectorFactory();

            Configuration config = eyes.GetConfiguration();

            config.AddBrowser(new DesktopBrowserInfo(new RectangleSize(700, 460), BrowserType.CHROME));
            config.AddDeviceEmulation(DeviceName.Galaxy_S3);
            config.AddBrowser(new IosDeviceInfo(IosDeviceName.iPhone_11_Pro));
            config.AddBrowser(new IosDeviceInfo(IosDeviceName.iPhone_XR));
            config.SetBatch(TestDataProvider.BatchInfo);
            config.SetAppName("Visual Grid DotNet Tests");
            config.SetTestName("UFG Mobile Device No Result");
            eyes.SetConfiguration(config);

            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

            driver.Url = "https://demo.applitools.com";
            try
            {
                eyes.Open(driver);
                eyes.Check(Target.Window());
                eyes.CloseAsync();
            }
            finally
            {
                driver.Quit();
                eyes.AbortAsync();
            }

            TestResultsSummary allTestResults = runner.GetAllTestResults(false);

            Assert.AreEqual(4, allTestResults.GetAllResults().Length);

            // Set results in array
            TestResults[] testResults = new TestResults[4];
            foreach (TestResultContainer resultsContainer in allTestResults)
            {
                RenderBrowserInfo browserInfo = resultsContainer.BrowserInfo;
                TestResults       results     = resultsContainer.TestResults;
                if (browserInfo.IosDeviceInfo == null && browserInfo.EmulationInfo == null)
                {
                    testResults[0] = results;
                    continue;
                }

                if (browserInfo.EmulationInfo != null)
                {
                    testResults[1] = results;
                    continue;
                }

                IosDeviceName deviceName = browserInfo.IosDeviceInfo.DeviceName;
                if (deviceName == IosDeviceName.iPhone_11_Pro)
                {
                    testResults[2] = results;
                    continue;
                }

                if (deviceName == IosDeviceName.iPhone_XR)
                {
                    testResults[3] = results;
                    continue;
                }

                Assert.Fail();
            }

            SessionResults chromeSessionResults         = TestUtils.GetSessionResults(eyes.ApiKey, testResults[0]);
            string         actualUserAgent              = chromeSessionResults.StartInfo.Environment.Inferred;
            Dictionary <BrowserType, string> userAgents = eyes.visualGridEyes_.eyesConnector_.GetUserAgents();

            Assert.AreEqual("useragent: " + userAgents[BrowserType.CHROME], actualUserAgent);

            Assert.AreEqual(new RectangleSize(700, 460), testResults[0].HostDisplaySize);
            Assert.AreEqual(new RectangleSize(360, 640), testResults[1].HostDisplaySize);
            Assert.AreEqual(new RectangleSize(375, 812), testResults[2].HostDisplaySize);
            Assert.AreEqual(new RectangleSize(414, 896), testResults[3].HostDisplaySize);
        }
Beispiel #28
0
        public void TestMapRunningTestsToRequiredBrowserWidth()
        {
            WebDriverProvider       webdriverProvider      = new WebDriverProvider();
            IServerConnectorFactory serverConnectorFactory = new MockServerConnectorFactory(webdriverProvider);
            ILogHandler             logHandler             = TestUtils.InitLogHandler();
            VisualGridRunner        runner = new VisualGridRunner(30, nameof(TestMapRunningTestsToRequiredBrowserWidth),
                                                                  serverConnectorFactory, logHandler);

            Eyes wrappingEyes = new Eyes(runner);

            Configuration configuration = wrappingEyes.GetConfiguration();

            configuration.AddBrowser(new DesktopBrowserInfo(1000, 500, BrowserType.CHROME));
            configuration.AddBrowser(new DesktopBrowserInfo(1000, 700, BrowserType.CHROME));
            configuration.AddBrowser(new DesktopBrowserInfo(700, 500, BrowserType.CHROME));
            wrappingEyes.SetConfiguration(configuration);

            VisualGridEyes eyes = wrappingEyes.visualGridEyes_;

            //doNothing().when(eyes).setViewportSize(ArgumentMatchers.< EyesSeleniumDriver > any());
            //eyes.ServerConnector(new MockServerConnector());

            //RemoteWebDriver driver = mock(RemoteWebDriver.class);
            //when(driver.getSessionId()).thenReturn(mock(SessionId.class));
            ChromeDriver driver = SeleniumUtils.CreateChromeDriver();

            webdriverProvider.SetDriver(driver);
            try
            {
                driver.Url = "data:text/html,<html><body><h1>Hello, world!</h1></body></html>";
                eyes.Open(driver, "app", "test", new Size(800, 800));

                Fluent.SeleniumCheckSettings          seleniumCheckSettings = Target.Window();
                Dictionary <int, List <RunningTest> > map = eyes.MapRunningTestsToRequiredBrowserWidth_(seleniumCheckSettings);
                CollectionAssert.IsEmpty(map);

                seleniumCheckSettings = Target.Window().LayoutBreakpointsEnabled(false);
                map = eyes.MapRunningTestsToRequiredBrowserWidth_(seleniumCheckSettings);
                CollectionAssert.IsEmpty(map);

                seleniumCheckSettings = Target.Window().LayoutBreakpointsEnabled(true);
                map = eyes.MapRunningTestsToRequiredBrowserWidth_(seleniumCheckSettings);
                CollectionAssert.AreEquivalent(new int[] { 700, 1000 }, map.Keys);
                Assert.AreEqual(1, map[700].Count);
                Assert.AreEqual(2, map[1000].Count);

                seleniumCheckSettings = Target.Window().LayoutBreakpoints(750, 1200);
                map = eyes.MapRunningTestsToRequiredBrowserWidth_(seleniumCheckSettings);
                CollectionAssert.AreEquivalent(new int[] { 749, 750 }, map.Keys);
                Assert.AreEqual(1, map[749].Count);
                Assert.AreEqual(2, map[750].Count);

                seleniumCheckSettings = Target.Window().LayoutBreakpoints(700);
                map = eyes.MapRunningTestsToRequiredBrowserWidth_(seleniumCheckSettings);
                CollectionAssert.AreEquivalent(new int[] { 700 }, map.Keys);
                Assert.AreEqual(3, map[700].Count);

                wrappingEyes.SetConfiguration(configuration.SetLayoutBreakpointsEnabled(false));
                seleniumCheckSettings = Target.Window();
                map = eyes.MapRunningTestsToRequiredBrowserWidth_(seleniumCheckSettings);
                CollectionAssert.IsEmpty(map);

                wrappingEyes.SetConfiguration(configuration.SetLayoutBreakpointsEnabled(true));
                seleniumCheckSettings = Target.Window();
                map = eyes.MapRunningTestsToRequiredBrowserWidth_(seleniumCheckSettings);
                CollectionAssert.AreEquivalent(new int[] { 700, 1000 }, map.Keys);
                Assert.AreEqual(1, map[700].Count);
                Assert.AreEqual(2, map[1000].Count);

                wrappingEyes.SetConfiguration(configuration.SetLayoutBreakpoints(750, 1200));
                seleniumCheckSettings = Target.Window();
                map = eyes.MapRunningTestsToRequiredBrowserWidth_(seleniumCheckSettings);
                CollectionAssert.AreEquivalent(new int[] { 749, 750 }, map.Keys);
                Assert.AreEqual(1, map[749].Count);
                Assert.AreEqual(2, map[750].Count);

                wrappingEyes.SetConfiguration(configuration.SetLayoutBreakpoints(750, 1200));
                seleniumCheckSettings = Target.Window().LayoutBreakpointsEnabled(true);
                map = eyes.MapRunningTestsToRequiredBrowserWidth_(seleniumCheckSettings);
                CollectionAssert.AreEquivalent(new int[] { 700, 1000 }, map.Keys);
                Assert.AreEqual(1, map[700].Count);
                Assert.AreEqual(2, map[1000].Count);

                wrappingEyes.SetConfiguration(configuration.SetLayoutBreakpoints(750, 1200));
                seleniumCheckSettings = Target.Window().LayoutBreakpoints(700);
                map = eyes.MapRunningTestsToRequiredBrowserWidth_(seleniumCheckSettings);
                CollectionAssert.AreEquivalent(new int[] { 700 }, map.Keys);
                Assert.AreEqual(3, map[700].Count);
            }
            finally
            {
                driver.Quit();
                runner.StopServiceRunner();
            }
        }
        public void ViewportsTest()
        {
            VisualGridRunner runner = new VisualGridRunner(30);
            Eyes             eyes   = new Eyes(runner);

            eyes.SetLogHandler(TestUtils.InitLogHandler());

            Configuration sconf = new Configuration();

            sconf.SetBatch(TestDataProvider.BatchInfo);
            sconf.SetTestName("Viewport Size Test");
            sconf.SetAppName("Visual Grid Viewports Test");
            sconf.SetHideScrollbars(true);
            sconf.SetStitchMode(StitchModes.CSS);
            sconf.SetForceFullPageScreenshot(true);
            sconf.SetMatchLevel(MatchLevel.Strict);
            int numOfBrowsers = 0;

            foreach (BrowserType b in Enum.GetValues(typeof(BrowserType)))
            {
#pragma warning disable CS0618 // Type or member is obsolete
                if (b == BrowserType.EDGE)
                {
                    continue;
                }
#pragma warning restore CS0618 // Type or member is obsolete
                sconf.AddBrowser(700, 500, b);
                sconf.AddBrowser(800, 600, b);
                numOfBrowsers++;
            }
            eyes.SetConfiguration(sconf);

            ChromeDriver driver = SeleniumUtils.CreateChromeDriver();
            eyes.Open(driver);
            driver.Url = "https://www.applitools.com";
            eyes.Check("Test Viewport", Target.Window().Fully());
            driver.Quit();

            TestResultsSummary allResults = runner.GetAllTestResults(false);
            Assert.Greater(sconf.GetBrowsersInfo().Count, numOfBrowsers);

            Dictionary <string, HashSet <Size> > results = new Dictionary <string, HashSet <Size> >();
            foreach (TestResultContainer testResultContainer in allResults)
            {
                Assert.NotNull(testResultContainer, nameof(testResultContainer));
                SessionResults sessionResults = TestUtils.GetSessionResults(eyes.ApiKey, testResultContainer.TestResults);
                if (sessionResults == null)
                {
                    eyes.Logger.Log("Error: sessionResults is null for item {0}", testResultContainer);
                    continue;
                }
                BaselineEnv env     = sessionResults.Env;
                string      browser = env.HostingAppInfo;
                if (browser == null)
                {
                    eyes.Log("Error: HostingAppInfo (browser) is null. {0}", testResultContainer);
                    continue;
                }
                if (!results.TryGetValue(browser, out HashSet <Size> sizesList))
                {
                    sizesList = new HashSet <Size>();
                    results.Add(browser, sizesList);
                }
                Size displaySize = env.DisplaySize;
                if (sizesList.Contains(displaySize))
                {
                    Assert.Fail($"Browser {browser} viewport size {displaySize} already exist in results.");
                }
                sizesList.Add(displaySize);
            }
            Assert.AreEqual(numOfBrowsers, results.Count, "unique browsers in results");
            Assert.AreEqual(sconf.GetBrowsersInfo().Count, allResults.Count, "all results");
        }
        public void TestVisualGridOptions()
        {
            // We want VG mode
            EyesRunner runner = new VisualGridRunner(10);
            Eyes       eyes   = new Eyes(runner);

            TestUtils.SetupLogging(eyes);
            eyes.visualGridEyes_.EyesConnectorFactory = new Mock.MockEyesConnectorFactory();

            Configuration config = eyes.GetConfiguration();

            config.AddBrowser(800, 600, BrowserType.CHROME);
            config.SetVisualGridOptions(new VisualGridOption("option1", "value1"), new VisualGridOption("option2", false));
            config.SetBatch(TestDataProvider.BatchInfo);
            eyes.SetConfiguration(config);

            MockEyesConnector mockEyesConnector;

            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

            driver.Url = "https://applitools.github.io/demo/TestPages/DynamicResolution/desktop.html";
            try
            {
                // First check - global + fluent config
                mockEyesConnector = OpenEyesAndGetConnector_(eyes, config, driver);
                eyes.Check(Target.Window().VisualGridOptions(new VisualGridOption("option3", "value3"), new VisualGridOption("option4", 5)));
                eyes.Close();
                var expected1 = new Dictionary <string, object>()
                {
                    { "option1", "value1" }, { "option2", false }, { "option3", "value3" }, { "option4", 5 }
                };
                var actual1 = mockEyesConnector.LastRenderRequests[0].Options;
                CollectionAssert.AreEquivalent(expected1, actual1);


                // Second check - only global
                mockEyesConnector = OpenEyesAndGetConnector_(eyes, config, driver);
                eyes.CheckWindow();
                eyes.Close();
                var expected2 = new Dictionary <string, object>()
                {
                    { "option1", "value1" }, { "option2", false }
                };
                var actual2 = mockEyesConnector.LastRenderRequests[0].Options;
                CollectionAssert.AreEquivalent(expected2, actual2);

                // Third check - resetting
                mockEyesConnector = OpenEyesAndGetConnector_(eyes, config, driver);
                config            = eyes.GetConfiguration();
                config.SetVisualGridOptions(null);
                eyes.SetConfiguration(config);
                eyes.CheckWindow();
                eyes.Close();
                var actual3 = mockEyesConnector.LastRenderRequests[0].Options;
                Assert.IsNull(actual3);
                runner.GetAllTestResults();
            }
            finally
            {
                eyes.AbortIfNotClosed();
                driver.Close();
            }
        }