Beispiel #1
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();
        }
Beispiel #2
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 TestMobileOnly()
        {
            VisualGridRunner runner = new VisualGridRunner(30);
            Eyes             eyes   = new Eyes(runner);

            eyes.SetLogHandler(TestUtils.InitLogHandler());

            Configuration sconf = new Configuration();

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

            sconf.AddDeviceEmulation(DeviceName.Galaxy_S5);

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

            eyes.Open(driver);
            driver.Url = "https://applitools.github.io/demo/TestPages/DynamicResolution/mobile.html";
            eyes.Check("Test Mobile Only", Target.Window().Fully());
            driver.Quit();
            eyes.Close();
            TestResultsSummary allResults = runner.GetAllTestResults();
        }
Beispiel #4
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();
            }
        }
Beispiel #5
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 #6
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);
        }
        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 #8
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);
        }