public void TestCreateDomSnapshotCollectsCookiesWhenDisabledUsingFluentApi()
        {
            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

            driver.Url = "http://applitools.github.io/demo/TestPages/CookiesTestPage/";
            Eyes             eyes   = Setup(driver);
            VisualGridRunner runner = (VisualGridRunner)eyes.runner_;

            try
            {
                Configuration config = eyes.GetConfiguration();
                config
                .SetAppName("test app").SetTestName("test name")
                .SetBatch(TestDataProvider.BatchInfo);
                eyes.SetConfiguration(config);
                EyesWebDriver eyesDriver            = (EyesWebDriver)eyes.Open(driver);
                EyesWebDriverTargetLocator switchTo = (EyesWebDriverTargetLocator)eyesDriver.SwitchTo();
                UserAgent userAgent    = UserAgent.ParseUserAgentString(eyesDriver.GetUserAgent());
                FrameData scriptResult = VisualGridEyes.CaptureDomSnapshot_(
                    switchTo, userAgent, config, Target.Window().UseCookies(false), runner, eyesDriver, runner.Logger);

                Assert.IsNull(scriptResult.Cookies);
                Assert.IsNull(scriptResult.Frames[0].Cookies);
                Assert.IsNull(scriptResult.Frames[0].Frames[0].Cookies);
            }
            finally
            {
                driver.Quit();
                eyes.AbortIfNotClosed();
                runner.StopServiceRunner();
            }
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        public void TestRegionBiggerThanViewport()
        {
            Eyes eyes = new Eyes();

            TestUtils.SetupLogging(eyes);

            eyes.SendDom                 = false;
            eyes.MatchTimeout            = TimeSpan.Zero;
            eyes.ForceFullPageScreenshot = true;

            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

            try
            {
                IWebDriver innerDriver = eyes.Open(driver, "maybelline", "maybelline", new Size(800, 800));
                driver.Url = "https://www.maybelline.com.sg/face";
                eyes.Check(Target.Region(By.CssSelector("body > div.container > div.site-container")));
                eyes.Close();
            }
            finally
            {
                driver.Quit();
                eyes.AbortIfNotClosed();
            }
        }
Esempio n. 4
0
        public void TestVanguard()
        {
            VisualGridRunner runner = new VisualGridRunner(10);
            IWebDriver       driver = SeleniumUtils.CreateChromeDriver();
            Eyes             eyes   = InitEyes(driver, runner, "https://investor.vanguard.com/home/", 1000, 700, false);

            Thread.Sleep(2000);
            try
            {
                eyes.Check("Vanguard",
                           Target
                           .Window()
                           .Fully()
                           .Strict()
                           .SendDom(false)
                           .Layout(By.ClassName("vgc-feedbackLink"))
                           );
                eyes.CloseAsync();
                runner.GetAllTestResults();
            }
            finally
            {
                eyes.Abort();
                driver.Quit();
            }
        }
Esempio n. 5
0
        public void IOSSimulatorUfgTest()
        {
            ILogHandler      logHandler = TestUtils.InitLogHandler();
            VisualGridRunner runner     = new VisualGridRunner(10, logHandler);
            Eyes             eyes       = new Eyes(runner);
            IWebDriver       driver     = SeleniumUtils.CreateChromeDriver();

            try
            {
                IConfiguration config = eyes.GetConfiguration();
                config.SaveDiffs = false;
                config.Batch     = TestDataProvider.BatchInfo;
                config.AddBrowser(new IosDeviceInfo(IosDeviceName.iPhone_XR, ScreenOrientation.Landscape));
                eyes.SetConfiguration(config);

                driver.Url = "http://applitools.github.io/demo";
                eyes.Open(driver, "Eyes SDK", "UFG Mobile Happy Flow", new Size(800, 600));
                eyes.CheckWindow();
                eyes.Close();
            }
            finally
            {
                eyes.AbortIfNotClosed();
                driver.Quit();
                runner.GetAllTestResults();
            }
        }
        public void TestEyesDifferentRunners(string testedUrl, MatchLevel matchLevel)
        {
            IWebDriver webDriver = SeleniumUtils.CreateChromeDriver();
            Logger     logger    = null;
            Eyes       eyes      = null;

            try
            {
                webDriver.Url     = testedUrl;
                eyes              = InitEyes(webDriver, testedUrl);
                eyes.SaveNewTests = false;
                logger            = eyes.Logger;
                logger.Log("running check for url " + testedUrl);
                ICheckSettings checkSettings = GetCheckSettings();
                eyes.MatchLevel = matchLevel;
                eyes.Check(checkSettings.WithName("Step1 - " + testedUrl));
                eyes.Check(checkSettings.Fully().WithName("Step2 - " + testedUrl));
                logger.Verbose("calling eyes_.Close() (test: {0})", testedUrl);
                TestResults results = eyes.Close(false);
                ValidateResults(eyes, results);
            }
            finally
            {
                eyes?.Abort();
                webDriver.Quit();
            }
        }
Esempio n. 7
0
        public void TestParseScriptResult()
        {
            Logger logger = InitLogging(out string path);

            IDictionary <Uri, ResourceFuture>         cache    = new ConcurrentDictionary <Uri, ResourceFuture>();
            ConcurrentDictionary <Uri, RGridResource> allBlobs = new ConcurrentDictionary <Uri, RGridResource>();
            HashSet <Uri> resourceUrls = new HashSet <Uri>();

            FileDebugResourceWriter debugResourceWriter = new FileDebugResourceWriter(path);
            RenderingTask           renderingTask       = new RenderingTask(logger, null, cache, null, null, debugResourceWriter);

            VisualGridEyes eyes = new VisualGridEyes(new ConfigurationProviderForTesting());

            eyes.SetLogHandler(logger.GetILogHandler());

            IWebDriver webDriver = SeleniumUtils.CreateChromeDriver();

            webDriver.Url = "http://applitools.github.io/demo/TestPages/FramesTestPage/";
            eyes.InitDriver(webDriver);
            try
            {
                string    scriptResult = eyes.GetDomCaptureAndPollingScriptResult_();
                FrameData frameData    = JsonConvert.DeserializeObject <FrameData>(scriptResult);
                renderingTask.ParseScriptResult_(frameData, allBlobs, resourceUrls);
            }
            finally
            {
                webDriver.Quit();
            }
        }
        public void Trello_1661_Garmin_31839()
        {
            EyesRunner runner = new ClassicRunner();

            Eyes eyes = new Eyes(runner);

            TestUtils.SetupLogging(eyes);
            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);

            try
            {
                eyes.Open(driver, "Ticket31839", "Test", new Size(1200, 700));
                driver.Url = "https://www.garmin.com/en-US/account/create/";
                driver.FindElement(By.Id("emailMatch")).SendKeys("*****@*****.**");
                eyes.Check("TAG NAME", Target.Region(By.CssSelector("#content > section > div")).Fully()
                           //.ScrollRootElement(By.TagName("body"))
                           );
                eyes.Close();
            }
            finally
            {
                driver.Close();
                eyes.AbortIfNotClosed();
            }
        }
Esempio n. 9
0
        public void TestDoubleCheckDontGetAllResults(bool useVisualGrid)
        {
            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

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

            string      suffix     = useVisualGrid ? "_VG" : "";
            ILogHandler logHandler = TestUtils.InitLogHandler(nameof(TestDoubleCheckDontGetAllResults) + suffix);
            EyesRunner  runner     = useVisualGrid ? (EyesRunner) new VisualGridRunner(10, logHandler) : new ClassicRunner(logHandler);

            try
            {
                Eyes eyes = new Eyes(runner);
                eyes.Batch = TestDataProvider.BatchInfo;
                eyes.Open(driver, "Applitools Eyes SDK", nameof(TestDoubleCheckDontGetAllResults) + suffix, new RectangleSize(1200, 800));
                eyes.Check(Target.Window().WithName("Step 1"));
                eyes.Check(Target.Window().WithName("Step 2"));
                eyes.Close(false);
            }
            finally
            {
                driver.Quit();
            }
            Assert.IsFalse(runner.GetAllTestResultsAlreadyCalled);
            (runner as VisualGridRunner)?.StopServiceRunner();
        }
        public void TestDoubleOpenCheckCloseWithDifferentInstances(bool useVisualGrid)
        {
            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

            driver.Url = "https://applitools.github.io/demo/TestPages/VisualGridTestPage/";

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

            runner.SetLogHandler(TestUtils.InitLogHandler());

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

            try
            {
                Eyes eyes1 = new Eyes(runner);
                eyes1.Batch = TestDataProvider.BatchInfo;
                eyes1.Open(driver, "Applitools Eyes SDK", nameof(TestDoubleOpenCheckCloseWithDifferentInstances) + suffix, new RectangleSize(1200, 800));
                eyes1.Check(Target.Window().Fully().IgnoreDisplacements(false).WithName("Step 1"));
                eyes1.Close(false);

                Eyes eyes2 = new Eyes(runner);
                eyes2.Batch = TestDataProvider.BatchInfo;
                eyes2.Open(driver, "Applitools Eyes SDK", nameof(TestDoubleOpenCheckCloseWithDifferentInstances) + suffix, new RectangleSize(1200, 800));
                eyes2.Check(Target.Window().Fully().IgnoreDisplacements(false).WithName("Step 2"));
                eyes2.Close(false);
            }
            finally
            {
                driver.Quit();
            }
            TestResultsSummary allTestResults = runner.GetAllTestResults(false);

            Assert.AreEqual(2, allTestResults.Count);
        }
        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();
        }
Esempio n. 12
0
        public void TestIsDisabled()
        {
            IWebDriver driver = SeleniumUtils.CreateChromeDriver();
            Eyes       eyes   = new Eyes();

            eyes.Batch = TestDataProvider.BatchInfo;
            TestUtils.SetupLogging(eyes);
            eyes.IsDisabled = true;
            try
            {
                eyes.Open(driver, "Demo C# app", "hello world", new Size(800, 600));

                driver.Url = "https://applitools.com/helloworld?diff1";
                eyes.Check(Target.Window().Fully());
                eyes.Check("Number test", Target.Region(By.ClassName("random-number")));
                eyes.Check(Target.Window().WithName("1"), Target.Region(By.Id("SomeId")).WithName("2"));
                eyes.CheckFrame(new string[] { "a", "b" }, TimeSpan.FromSeconds(1));

                eyes.Close();
            }
            finally
            {
                driver.Quit();
                eyes.AbortIfNotClosed();
            }
        }
Esempio n. 13
0
        public void Test_VG_RCA_Fluent()
        {
            EyesRunner runner = new VisualGridRunner(10);
            Eyes       eyes   = new Eyes(runner);

            eyes.Batch = batch_;
            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

            try
            {
                driver.Url = "https://applitools.github.io/demo/TestPages/VisualGridTestPage";

                driver.SwitchTo().Frame("iframe");
                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
                wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("#p2")));
                driver.SwitchTo().DefaultContent();

                eyes.Open(driver, "Test Visual Grid", "Test RCA Fluent");
                eyes.SendDom = false;
                eyes.Check(Target.Window().SendDom(true));
                eyes.Close();
                runner.GetAllTestResults();
            }
            finally
            {
                driver.Quit();
            }
        }
        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);
            }
        }
        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);
        }
Esempio n. 16
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 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);
        }
Esempio n. 18
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();
        }
Esempio n. 19
0
        public void TestCloseAsync(bool useVisualGrid)
        {
            IWebDriver  driver     = SeleniumUtils.CreateChromeDriver();
            string      logPath    = TestUtils.InitLogPath();
            ILogHandler logHandler = TestUtils.InitLogHandler(logPath: logPath);
            EyesRunner  runner     = useVisualGrid ? (EyesRunner) new VisualGridRunner(10, logHandler) : new ClassicRunner(logHandler);

            if (useVisualGrid && !TestUtils.RUNS_ON_CI)
            {
                ((VisualGridRunner)runner).DebugResourceWriter = new FileDebugResourceWriter(logPath);
            }
            Eyes eyes = new Eyes(runner);

            eyes.Batch = TestDataProvider.BatchInfo;
            try
            {
                driver.Url = "https://applitools.com/helloworld";
                eyes.Open(driver, nameof(TestApiMethods), nameof(TestCloseAsync) + "_1", new Size(800, 600));
                eyes.Check(Target.Window().WithName("step 1"));
                eyes.CloseAsync();
                driver.FindElement(By.TagName("button")).Click();
                eyes.Open(driver, nameof(TestApiMethods), nameof(TestCloseAsync) + "_2", new Size(800, 600));
                eyes.Check(Target.Window().WithName("step 2"));
                eyes.CloseAsync();
                runner.GetAllTestResults();
            }
            finally
            {
                driver.Quit();
            }
        }
        public void Test()
        {
            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

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

            BatchInfo        batch      = new BatchInfo("Visual Grid - Test bad webhook");
            ILogHandler      logHandler = TestUtils.InitLogHandler(nameof(TestVGWithBadWebhook));
            VisualGridRunner runner     = new VisualGridRunner(10, logHandler);
            Eyes             eyes       = new Eyes(runner);

            Configuration config = new Configuration();

            config.SetBatch(batch);
            config.SetAppName("Visual Grid Tests");
            config.SetTestName("Bad Webhook");
            config.SetViewportSize(new Applitools.Utils.Geometry.RectangleSize(800, 600));

            eyes.SetConfiguration(config);
            eyes.Open(driver);
            try
            {
                eyes.Check(Target.Window().Fully().BeforeRenderScreenshotHook("gibberish uncompilable java script"));
                driver.Quit();
                Assert.That(() =>
                {
                    eyes.Close();
                    runner.GetAllTestResults();
                }, Throws.Exception.With.InstanceOf <EyesException>().With.InnerException.With.Property("Message").StartsWith("Render Failed for DesktopBrowserInfo {ViewportSize={Width=800, Height=600}, BrowserType=CHROME} "));
            }
            finally
            {
                runner.StopServiceRunner();
            }
        }
Esempio n. 21
0
        public void TestAgilent()
        {
            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

            try
            {
                List <string> URLs = GetUrls();
                int           ctr  = 0;
                foreach (string url in URLs)
                {
                    ctr++;
                    EyesRunner runner = new VisualGridRunner(10);
                    Eyes       eyes   = new Eyes(runner);

                    RunVisualTest(driver, eyes, url, appName, "Test url: " + url);
                    runner.GetAllTestResults(false);

                    runner = null;
                    eyes   = null;
                    GC.Collect();
                }
            }
            finally
            {
                driver.Quit();
            }
        }
Esempio n. 22
0
        public void TestWebsiteThatRequireScrolling(string website, string name)
        {
            VisualGridRunner runner = new VisualGridRunner(10);
            IWebDriver       driver = SeleniumUtils.CreateChromeDriver();
            Eyes             eyes   = InitEyesWithLogger(runner, writeResources: true, verbose: true, testMethod: name);

            ConfigureMultipleBrowsers(eyes);

            try
            {
                EyesWebDriver        eyesWebDriver = (EyesWebDriver)OpenEyes(driver, website, eyes, 1000, 700, name);;
                EyesRemoteWebElement html          = (EyesRemoteWebElement)eyesWebDriver.FindElement(By.TagName("html"));
                eyesWebDriver.ExecuteAsyncScript(@"var currScrollPosition = 0;
                    let cb = arguments[arguments.length - 1]
                    var interval = setInterval(function() {
                    let scrollPosition = document.documentElement.scrollTop;
                    currScrollPosition += 300;
                    window.scrollTo(0, currScrollPosition);
                    if (scrollPosition === document.documentElement.scrollTop)
                    {
                        clearInterval(interval);
                        window.scrollTo(0, 0);
                        cb()
                    }
                    }, 100); ");
                eyes.Check(name, Target.Window().Fully());
                eyes.CloseAsync();
                runner.GetAllTestResults();
            }
            finally
            {
                eyes.Abort();
                driver.Quit();
            }
        }
Esempio n. 23
0
        public void TestSimpleCodedRegions()
        {
            IWebDriver webDriver = SeleniumUtils.CreateChromeDriver();

            webDriver.Manage().Window.Size = new Size(740, 600);
            webDriver.Url = "data:text/html,<!DOCTYPE html><html><body><header style='height: 50px'>header</header><main style='position: relative;'><section><div style='position: relative; border: 3px blue solid; height: 30px;'>box</div></section></main></body></html>";

            try
            {
                IWebElement         headerElement = webDriver.FindElement(By.CssSelector("header"));
                IWebElement         mainElement   = webDriver.FindElement(By.CssSelector("main"));
                IWebElement         boxElement    = webDriver.FindElement(By.CssSelector("div"));
                IJavaScriptExecutor jsExecutor    = (IJavaScriptExecutor)webDriver;
                Rectangle           headerRect    = EyesRemoteWebElement.GetVisibleElementRect(headerElement, jsExecutor);
                Rectangle           mainRect      = EyesRemoteWebElement.GetVisibleElementRect(mainElement, jsExecutor);
                Rectangle           boxRect       = EyesRemoteWebElement.GetVisibleElementRect(boxElement, jsExecutor);
                Assert.AreEqual(new Rectangle(8, 8, 724, 50), headerRect);
                Assert.AreEqual(new Rectangle(8, 58, 724, 36), mainRect);
                Assert.AreEqual(new Rectangle(8, 58, 724, 36), boxRect);
            }
            finally
            {
                webDriver.Quit();
            }
        }
Esempio n. 24
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);
        }
Esempio n. 25
0
        public void TestNoReplaceMatchedStep()
        {
            WebDriverProvider webdriverProvider = new WebDriverProvider();
            Eyes eyes = new Eyes(new MockServerConnectorFactory(webdriverProvider));

            TestUtils.SetupLogging(eyes);
            eyes.Batch = TestDataProvider.BatchInfo;
            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

            webdriverProvider.SetDriver(driver);
            MockServerConnector mockServerConnector = (MockServerConnector)eyes.seleniumEyes_.ServerConnector;

            mockServerConnector.AsExpected = false;
            try
            {
                driver.Url = "https://applitools.github.io/demo/TestPages/SpecialCases/neverchanging.html";
                eyes.Open(driver, "Applitools Eyes SDK", "Test No Replace Matched Step", new Size(700, 460));
                eyes.Check("Step 1", Target.Window().SendDom(false));
                eyes.Close();
            }
            finally
            {
                driver.Quit();
                eyes.AbortIfNotClosed();
            }
            Assert.AreEqual(1, mockServerConnector.MatchWindowCalls.Count, "Matches");
            Assert.AreEqual(0, mockServerConnector.ReplaceMatchedStepCalls.Count, "Replacements");
        }
Esempio n. 26
0
        public void Test_VG_RCA_Config()
        {
            ILogHandler      logHandler = TestUtils.InitLogHandler();
            VisualGridRunner runner     = new VisualGridRunner(10, logHandler);
            Eyes             eyes       = new Eyes(runner);

            eyes.Batch = batch_;
            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

            try
            {
                driver.Url = "https://applitools.github.io/demo/TestPages/VisualGridTestPage";
                driver.SwitchTo().Frame("iframe");
                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
                wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("svg")));
                driver.SwitchTo().ParentFrame();
                eyes.Open(driver, "Test Visual Grid", "Test RCA Config");
                eyes.SendDom = true;
                eyes.Check(Target.Window());
                eyes.Close();
                runner.GetAllTestResults();
            }
            finally
            {
                driver.Quit();
                eyes.AbortIfNotClosed();
                runner.StopServiceRunner();
            }
        }
        public void TestDoubleCheckDontGetAllResults(bool useVisualGrid)
        {
            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

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

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

            runner.SetLogHandler(TestUtils.InitLogHandler());

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

            try
            {
                Eyes eyes1 = new Eyes(runner);
                eyes1.Batch = TestDataProvider.BatchInfo;
                eyes1.Open(driver, "Applitools Eyes SDK", nameof(TestDoubleCheckDontGetAllResults) + suffix, new RectangleSize(1200, 800));
                eyes1.Check(Target.Window().WithName("Step 1"));
                eyes1.Check(Target.Window().WithName("Step 2"));
                eyes1.Close(false);
            }
            finally
            {
                driver.Quit();
            }
        }
Esempio n. 28
0
        //[Test]
        public void TestSendDOM_Simple_HTML()
        {
            IWebDriver webDriver = SeleniumUtils.CreateChromeDriver();

            webDriver.Url = "https://applitools-dom-capture-origin-1.surge.sh/test.html";
            Eyes eyes = new Eyes();

            try
            {
                EyesWebDriver eyesWebDriver = (EyesWebDriver)eyes.Open(webDriver, "Test Send DOM", "Test DomCapture method", new Size(1200, 1000));
                Logger        logger        = new Logger();
                logger.SetLogHandler(TestUtils.InitLogHandler());
                DomCapture domCapture          = new DomCapture(logger, eyesWebDriver);
                string     actualDomJsonString = domCapture.GetFullWindowDom();
                string     actualDomJson       = JsonUtility.NormalizeJsonString(actualDomJsonString);
                string     expectedDomJson     = GetExpectedDomFromUrl_("https://applitools-dom-capture-origin-1.surge.sh/test.dom.json");

                eyes.Close(false);

                Assert.AreEqual(expectedDomJson, actualDomJson);
            }
            finally
            {
                eyes.Abort();
                webDriver.Quit();
            }
        }
Esempio n. 29
0
        public void TestPandalytics()
        {
            VisualGridRunner runner = new VisualGridRunner(10);
            IWebDriver       driver = SeleniumUtils.CreateChromeDriver();
            Eyes             eyes   = InitEyesWithLogger(runner, verbose: true, writeResources: true);

            //ConfigureSingleBrowser(eyes);
            ConfigureMultipleBrowsers(eyes);
            try
            {
                EyesWebDriver eyesWebDriver = (EyesWebDriver)OpenEyes(driver, "https://pandalytics-sandbox.instructure.com", eyes, 1000, 700);
                driver.FindElement(By.Id("pseudonym_session_unique_id")).SendKeys("*****@*****.**");
                driver.FindElement(By.Id("pseudonym_session_password")).SendKeys("password");
                driver.FindElement(By.ClassName("Button--login")).Click();

                eyes.Check("Dashboard page", Target.Window().Fully());

                driver.Url = "https://pandalytics-sandbox.instructure.com/courses/17/external_tools/63";

                Thread.Sleep(1000);
                eyes.Check("LTI tool", Target.Frame("tool_content").Fully());
                eyes.CloseAsync();
                runner.GetAllTestResults();
            }
            finally
            {
                eyes.Abort();
                driver.Quit();
            }
        }
Esempio n. 30
0
        public void BeatsByDre_HoverElement(bool bCheckHover)
        {
            string testName = "Hover Element (viewport)";

            if (bCheckHover == true)
            {
                testName += " - On";
            }
            else
            {
                testName += " - Off";
            }

            Eyes eyes = new Eyes();

            IWebDriver driver  = SeleniumUtils.CreateChromeDriver();
            string     logPath = TestUtils.InitLogPath();

            eyes.DebugScreenshotProvider = new FileDebugScreenshotProvider()
            {
                Path = logPath
            };
            try
            {
                IWebDriver eyesDriver = eyes.Open(driver, testName, testName, new Size(1200, 600));

                driver.Url = "https://www.beatsbydre.com/support/headphones/studio3-wireless";

                ((ChromeDriver)driver).ExecuteScript("window.scrollBy(0,400)");

                By selector = By.CssSelector(
                    "#maincontent > div:nth-child(1) > div.supportContent.parbase.section > div > div > div.selector.topics > div.boxes > a:nth-child(1) > div > div.content");

                eyes.CheckWindow("Window", false);

                //eyes.StitchMode = StitchModes.CSS;
                // Hover effect
                if (bCheckHover)
                {
                    IWebElement we = eyesDriver.FindElement(selector);

                    Actions action = new Actions(eyesDriver);

                    action.MoveToElement(we).Perform();
                }
                // End

                eyes.CheckWindow("Window 2", false);

                eyes.Check("Region", Target.Region(selector));

                eyes.Close();
            }
            finally
            {
                eyes.Abort();
                driver.Quit();
            }
        }