예제 #1
0
        private static void CompareDomJsons(DomInterceptingEyes eyes, string actualDomJsonString, string expectedContentFilename)
        {
            string expectedDomJsonString = CommonUtils.ReadResourceFile(expectedContentFilename);
            string expectedDomJson       = JsonUtility.NormalizeJsonString(expectedDomJsonString);

            TestResults results = eyes.Close(false);
            bool        hasDom  = GetHasDom_(eyes, results);

            Assert.IsTrue(hasDom);

            string actualDomJson = JsonUtility.NormalizeJsonString(actualDomJsonString);

            if (actualDomJson != expectedDomJson && !TestUtils.RUNS_ON_CI)
            {
                string path = TestUtils.InitLogPath();
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                File.WriteAllText(Path.Combine(path, "actualDom.json"), actualDomJson);
            }
            Assert.AreEqual(expectedDomJson, actualDomJson);

            SessionResults sessionResults = TestUtils.GetSessionResults(eyes.ApiKey, results);

            ActualAppOutput[] actualAppOutput         = sessionResults.ActualAppOutput;
            string            downloadedDomJsonString = TestUtils.GetStepDom(eyes, actualAppOutput[0]);
            string            downloadedDomJson       = JsonUtility.NormalizeJsonString(downloadedDomJsonString);

            Assert.AreEqual(expectedDomJson, downloadedDomJson);
        }
예제 #2
0
        public void TestSendDOM_FullWindow()
        {
            IWebDriver webDriver = SeleniumUtils.CreateChromeDriver();

            webDriver.Url = "https://applitools.github.io/demo/TestPages/FramesTestPage/";
            DomInterceptingEyes eyes = new DomInterceptingEyes();

            eyes.Batch = TestDataProvider.BatchInfo;

            EyesWebDriver eyesWebDriver = (EyesWebDriver)eyes.Open(webDriver, "Test Send DOM", "Full Window", new Size(1024, 768));

            try
            {
                eyes.Check(Target.Window().Fully().WithName("Window"));
                string actualDomJsonString = eyes.DomJson;

                string expectedDomJsonString = CommonUtils.ReadResourceFile("Test.Eyes.Selenium.DotNet.Resources.expected_dom1.json");
                string expectedDomJson       = JsonUtility.NormalizeJsonString(expectedDomJsonString);

                TestResults results = eyes.Close(false);
                bool        hasDom  = GetHasDom_(eyes, results);
                Assert.IsTrue(hasDom);

                string actualDomJson = JsonUtility.NormalizeJsonString(actualDomJsonString);
                Assert.AreEqual(expectedDomJson, actualDomJson);

                SessionResults    sessionResults          = TestUtils.GetSessionResults(eyes.ApiKey, results);
                ActualAppOutput[] actualAppOutput         = sessionResults.ActualAppOutput;
                string            downloadedDomJsonString = TestUtils.GetStepDom(eyes, actualAppOutput[0]);
                string            downloadedDomJson       = JsonUtility.NormalizeJsonString(downloadedDomJsonString);
                Assert.AreEqual(expectedDomJson, downloadedDomJson);
            }
            finally
            {
                eyes.Abort();
                webDriver.Quit();
            }
        }
예제 #3
0
        public void TestSendDOM_FullWindow()
        {
            IWebDriver webDriver = SeleniumUtils.CreateChromeDriver();

            webDriver.Url = "https://applitools.github.io/demo/TestPages/FramesTestPage/";
            DomInterceptingEyes eyes = new DomInterceptingEyes();

            eyes.Batch = TestDataProvider.BatchInfo;

            EyesWebDriver eyesWebDriver = (EyesWebDriver)eyes.Open(webDriver, "Test Send DOM", "Window", new Size(1024, 768));

            try
            {
                eyes.Check(Target.Window().Fully().WithName("Window"));
                string actualDomJsonString = eyes.DomJson;
                CompareDomJsons(eyes, actualDomJsonString, "Test.Eyes.Selenium.DotNet.Resources.expected_dom_window.json");
            }
            finally
            {
                eyes.Abort();
                webDriver.Quit();
            }
        }