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 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 TearDown() { eyes.CloseAsync(); driver.Quit(); eyes.AbortIfNotClosed(); TestResultsSummary allTestResults = runner.GetAllTestResults(); }
public void AfterTestSuite() { // Close the browser. _driver.Quit(); // If the test was aborted before eyes.close was called, ends the test as aborted. _eyes.AbortIfNotClosed(); //Wait and collect all test results TestResultsSummary allTestResults = _runner.GetAllTestResults(); }
public void AfterTestSuite() { // Wait until the test results are available and retrieve them TestResultsSummary allTestResults = runner.GetAllTestResults(false); foreach (var result in allTestResults) { HandleTestResults(result); } }
private static void TearDown(IWebDriver driver, EyesRunner runner) { driver.Quit(); // Wait and collect all test results // we pass false to this method to suppress the exception that is thrown if we // find visual differences TestResultsSummary allTestResults = runner.GetAllTestResults(false); // Print results Console.WriteLine(allTestResults); }
public void AfterEach() { // Close the browser. driver.Quit(); // If the test was aborted before eyes.close was called, ends the test as aborted. eyes.AbortIfNotClosed(); //Wait and collect all test results // we pass false to this method to suppress the exception that is thrown if we // find visual differences TestResultsSummary allTestResults = runner.GetAllTestResults(false); // Print results Console.WriteLine(allTestResults); }
public void AfterScenario() { IWebDriver driver = null; try { driver = (IWebDriver)ScenarioContext.Current["WEBDRIVER"]; driver.Close(); driver.Quit(); driver = null; } catch (Exception e) { Console.WriteLine($"Selenium Web Driver not found to dispose. {e.Message}"); } finally { ScenarioContext.Current["WEBDRIVER"] = null; Console.WriteLine("After Scenario - Test Completed"); } //Close Eyes try { EyesRunner runner = (EyesRunner)ScenarioContext.Current["EYESRUNNER"]; Eyes eyes = (Eyes)ScenarioContext.Current["EYES"]; eyes.CloseAsync(); // If the test was aborted before eyes.close was called, ends the test as aborted. eyes.AbortIfNotClosed(); //Wait and collect all test results TestResultsSummary allTestResults = runner.GetAllTestResults(); }catch (Exception e) { } }
public void AfterSuite() { visualGridRunner.Logger.Log("After class"); visualGridRunner.Logger.Log("iterating through all webdrivers in pool"); foreach (IWebDriver webDriver in webDrivers) { try { visualGridRunner.Logger.Log("calling webdriver.quit (2)"); webDriver.Quit(); } catch (Exception e) { visualGridRunner.Logger.Log("Error: " + e); } } if (visualGridRunner != null) { visualGridRunner.Logger.Log("calling GetAllTestResults()"); TestResultsSummary allTestResults = visualGridRunner.GetAllTestResults(); } }
public static void FinalTearDown() { TestResultsSummary allTestResults = runner.GetAllTestResults(false); Console.WriteLine(allTestResults); }
public void TestAccessibility(bool useVisualGrid) { string suffix = useVisualGrid ? "_VG" : ""; ILogHandler logHandler = TestUtils.InitLogHandler(nameof(TestAccessibility) + suffix); EyesRunner runner = useVisualGrid ? (EyesRunner) new VisualGridRunner(10, logHandler) : new ClassicRunner(logHandler); Eyes eyes = new Eyes(runner); eyes.Batch = TestDataProvider.BatchInfo; AccessibilitySettings settings = new AccessibilitySettings(AccessibilityLevel.AA, AccessibilityGuidelinesVersion.WCAG_2_0); Configuration configuration = eyes.GetConfiguration(); configuration.SetAccessibilityValidation(settings); eyes.SetConfiguration(configuration); IWebDriver driver = SeleniumUtils.CreateChromeDriver(); try { driver.Url = "https://applitools.github.io/demo/TestPages/FramesTestPage/"; eyes.Open(driver, "Applitools Eyes SDK", "TestAccessibility_Sanity" + suffix, new Size(700, 460)); eyes.Check("Sanity", Target.Window().Accessibility(By.ClassName("ignore"), AccessibilityRegionType.LargeText)); eyes.CloseAsync(); configuration.SetAccessibilityValidation(null); eyes.SetConfiguration(configuration); eyes.Open(driver, "Applitools Eyes SDK", "TestAccessibility_No_Accessibility" + suffix, new Size(1200, 800)); eyes.CheckWindow("No accessibility"); eyes.CloseAsync(); } finally { driver.Quit(); eyes.AbortAsync(); TestResultsSummary allTestResults = runner.GetAllTestResults(false); Assert.AreEqual(2, allTestResults.Count); TestResults resultSanity = allTestResults[0].TestResults; TestResults resultNoAccessibility = allTestResults[1].TestResults; // Visual grid runner doesn't guarantee the order of the results if (resultNoAccessibility.Name.StartsWith("TestAccessibility_Sanity")) { TestResults temp = resultSanity; resultSanity = resultNoAccessibility; resultNoAccessibility = temp; } // Testing the accessibility status returned in the results SessionAccessibilityStatus accessibilityStatus = resultSanity.AccessibilityStatus; Assert.AreEqual(AccessibilityLevel.AA, accessibilityStatus.Level); Assert.AreEqual(AccessibilityGuidelinesVersion.WCAG_2_0, accessibilityStatus.Version); Assert.IsNull(resultNoAccessibility.AccessibilityStatus); // Testing the accessibility settings sent in the start info SessionResults sessionResults = TestUtils.GetSessionResults(eyes.ApiKey, resultSanity); Metadata.ImageMatchSettings defaultMatchSettings = sessionResults.StartInfo.DefaultMatchSettings; Assert.AreEqual(AccessibilityGuidelinesVersion.WCAG_2_0, defaultMatchSettings.AccessibilitySettings.GuidelinesVersion); Assert.AreEqual(AccessibilityLevel.AA, defaultMatchSettings.AccessibilitySettings.Level); // Testing the accessibility regions sent in the session var matchSettings = sessionResults.ActualAppOutput[0].ImageMatchSettings; var actualRegions = matchSettings.Accessibility; HashSet <AccessibilityRegionByRectangle> expectedRegions = new HashSet <AccessibilityRegionByRectangle>(); expectedRegions.Add(new AccessibilityRegionByRectangle(122, 933, 456, 306, AccessibilityRegionType.LargeText)); expectedRegions.Add(new AccessibilityRegionByRectangle(8, 1277, 690, 206, AccessibilityRegionType.LargeText)); if (useVisualGrid) { expectedRegions.Add(new AccessibilityRegionByRectangle(10, 286, 800, 500, AccessibilityRegionType.LargeText)); } else { expectedRegions.Add(new AccessibilityRegionByRectangle(10, 286, 285, 165, AccessibilityRegionType.LargeText)); } TestSetup.CompareAccessibilityRegionsList_(actualRegions, expectedRegions, "Accessibility"); } }
public void TestEyesConfiguration(bool useVisualGrid, string sequenceName, string sequenceNameEnvVar) { EyesRunner runner = useVisualGrid ? (EyesRunner) new VisualGridRunner(10) : new ClassicRunner(); Eyes eyes = new Eyes(runner); TestUtils.SetupLogging(eyes); IWebDriver driver = SeleniumUtils.CreateChromeDriver(); driver.Url = "https://applitools.github.io/demo/TestPages/FramesTestPage/"; string originalBatchSequence = Environment.GetEnvironmentVariable("APPLITOOLS_BATCH_SEQUENCE"); if (sequenceNameEnvVar != null) { Environment.SetEnvironmentVariable("APPLITOOLS_BATCH_SEQUENCE", sequenceNameEnvVar); } string effectiveSequenceName = sequenceName ?? sequenceNameEnvVar; BatchInfo batchInfo = new BatchInfo() { Id = TestDataProvider.BatchInfo.Id + "_" + effectiveSequenceName, Name = TestDataProvider.BatchInfo.Name + "_" + effectiveSequenceName }; if (sequenceName != null) { batchInfo.SequenceName = sequenceName; } if (sequenceNameEnvVar != null) { Environment.SetEnvironmentVariable("APPLITOOLS_BATCH_SEQUENCE", originalBatchSequence); } try { Assert.AreEqual(effectiveSequenceName, batchInfo.SequenceName, "SequenceName"); Configuration conf = new Configuration(); string testName = "Test - " + (useVisualGrid ? "Visual Grid" : "Selenium"); conf.SetAppName("app").SetTestName(testName) .SetHostApp("someHostApp").SetHostOS("someHostOs") //.SetBaselineBranchName("baseline branch") //.SetBaselineEnvName("baseline env") .SetEnvironmentName("env name") .SetBatch(batchInfo); eyes.SetConfiguration(conf); eyes.Open(driver); eyes.MatchLevel = MatchLevel.Layout; eyes.Check(Target.Window()); eyes.MatchLevel = MatchLevel.Content; eyes.Check(Target.Window()); } finally { driver.Quit(); } TestResults results = eyes.Close(false); Metadata.SessionResults sessionResults = TestUtils.GetSessionResults(eyes.ApiKey, results); Assert.NotNull(sessionResults, "SessionResults"); Assert.AreEqual("someHostOs", sessionResults.Env.Os, "OS"); Assert.AreEqual("someHostApp", sessionResults.Env.HostingApp, "Hosting App"); Assert.AreEqual(batchInfo.SequenceName, sessionResults.StartInfo.BatchInfo.SequenceName, "Sequence Name"); //Assert.AreEqual("baseline branch", sessionResults.BaselineBranchName); //Assert.AreEqual("baseline env", sessionResults.BaselineEnvId); Assert.NotNull(sessionResults.ActualAppOutput, "Actual App Output"); Assert.AreEqual(2, sessionResults.ActualAppOutput.Length, "Actual App Output"); Assert.AreEqual(MatchLevel.Layout2, sessionResults.ActualAppOutput[0].ImageMatchSettings.MatchLevel, "Actual App Output (Layout)"); Assert.AreEqual(MatchLevel.Content, sessionResults.ActualAppOutput[1].ImageMatchSettings.MatchLevel, "Actual App Output (Content)"); TestResultsSummary resultsSummary = runner.GetAllTestResults(false); eyes.Abort(); }
public void StatNavVisualTesting() { try { string _username = TestContext.Parameters.Get("now"); string _password = TestContext.Parameters.Get("next"); string url = TestContext.Parameters.Get("webAppUrl"); runner = new ClassicRunner(); eyes = new Eyes(runner); eyes.ApiKey = "975LpId103DAQlvQO4qrOra9deeNnZysqfEH4i4EZ48JMA110"; // Start the test by setting AUT's name, window or the page name that's being tested, viewport width and height eyes.Open(AppDriver.driver, "StatNav", "Visual_Testing", new Size(800, 600)); AppDriver.driver.Url = url; AppDriver.driver.Manage().Window.Maximize(); AppDriver.driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20); AppDriver.wait = new WebDriverWait(AppDriver.driver, TimeSpan.FromSeconds(70)); // Visual checkpoint #1 - Check the login page. eyes.CheckWindow("StatNav - Login Page"); StatNav spage = new StatNav(); AppDriver.wait.Until(ExpectedConditions.ElementToBeClickable(spage.Login)); spage.Login.Click(); AppDriver.wait.Until(ExpectedConditions.ElementToBeClickable(spage.MSAccount)); spage.MSAccount.SendKeys(_username); AppDriver.wait.Until(ExpectedConditions.ElementToBeClickable(spage.MSconfirm)); spage.MSconfirm.Click(); AppDriver.wait.Until(ExpectedConditions.ElementToBeClickable(spage.MSPwd)); spage.MSPwd.SendKeys(_password); AppDriver.wait.Until(ExpectedConditions.ElementToBeClickable(spage.MSconfirm)); spage.MSconfirm.Click(); AppDriver.wait.Until(ExpectedConditions.ElementToBeClickable(spage.MSconfirm)); spage.MSconfirm.Click(); // Visual checkpoint #2 - Check the app page. eyes.CheckWindow("StatNav - Home Page"); AppDriver.driver.FindElement(By.LinkText("Dashboard")).Click(); // Visual checkpoint #3 - Check the app page. eyes.CheckWindow("StatNav - Dashboard"); AppDriver.driver.FindElement(By.LinkText("Package Containers")).Click(); // Visual checkpoint #3 - Check the app page. eyes.CheckWindow("StatNav - Package Containers"); AppDriver.driver.FindElement(By.LinkText("Marketing Asset Packages")).Click(); // Visual checkpoint #3 - Check the app page. eyes.CheckWindow("StatNav - Marketing Asset Packages"); AppDriver.driver.FindElement(By.LinkText("Iterations")).Click(); // Visual checkpoint #3 - Check the app page. eyes.CheckWindow("StatNav - Iterations"); AppDriver.driver.FindElement(By.LinkText("Candidates")).Click(); // Visual checkpoint #3 - Check the app page. eyes.CheckWindow("StatNav - Candidates"); // End the test. eyes.CloseAsync(); AppDriver.driver.FindElement(By.XPath("/html/body/div[1]/div/div[2]/ul[2]/li[2]/a")).Click(); } finally { //AppDriver.driver.Quit(); // If the test was aborted before eyes.close was called, ends the test as aborted. eyes.AbortIfNotClosed(); //Wait and collect all test results TestResultsSummary allTestResults = runner.GetAllTestResults(); } }
public void TestChangeConfigAfterOpen(bool useVisualGrid) { IWebDriver driver = SeleniumUtils.CreateChromeDriver(); try { EyesRunner runner = useVisualGrid ? (EyesRunner) new VisualGridRunner(10) : new ClassicRunner(); Eyes eyes = new Eyes(runner); Configuration conf = new Configuration(); conf.SetAppName("app").SetTestName("test"); conf.SetBatch(TestDataProvider.BatchInfo); conf.SetAccessibilityValidation(null).SetIgnoreDisplacements(false); eyes.SetConfiguration(conf); eyes.Open(driver); eyes.CheckWindow(); conf.SetAccessibilityValidation(new AccessibilitySettings(AccessibilityLevel.AAA, AccessibilityGuidelinesVersion.WCAG_2_1)).SetIgnoreDisplacements(true); eyes.SetConfiguration(conf); eyes.CheckWindow(); conf.SetAccessibilityValidation(new AccessibilitySettings(AccessibilityLevel.AA, AccessibilityGuidelinesVersion.WCAG_2_0)).SetMatchLevel(MatchLevel.Layout); eyes.SetConfiguration(conf); eyes.CheckWindow(); eyes.Close(false); TestResultsSummary resultsSummary = runner.GetAllTestResults(false); Assert.AreEqual(1, resultsSummary.Count); TestResultContainer resultsContainer = resultsSummary[0]; TestResults results = resultsContainer.TestResults; SessionResults sessionResults = TestUtils.GetSessionResults(eyes.ApiKey, results); string browserInfo = resultsContainer.BrowserInfo?.ToString(); Assert.IsNull(sessionResults.StartInfo.DefaultMatchSettings.AccessibilitySettings, browserInfo); Assert.IsFalse(sessionResults.StartInfo.DefaultMatchSettings.IgnoreDisplacements, browserInfo); Assert.AreEqual(MatchLevel.Strict, sessionResults.StartInfo.DefaultMatchSettings.MatchLevel, browserInfo); Assert.AreEqual(3, sessionResults.ActualAppOutput.Length, browserInfo); Assert.IsNull(sessionResults.ActualAppOutput[0].ImageMatchSettings.AccessibilitySettings, browserInfo); Assert.AreEqual(AccessibilityLevel.AAA, sessionResults.ActualAppOutput[1].ImageMatchSettings.AccessibilitySettings.Level, browserInfo); Assert.AreEqual(AccessibilityGuidelinesVersion.WCAG_2_1, sessionResults.ActualAppOutput[1].ImageMatchSettings.AccessibilitySettings.GuidelinesVersion, browserInfo); Assert.IsTrue(sessionResults.ActualAppOutput[1].ImageMatchSettings.IgnoreDisplacements, browserInfo); Assert.AreEqual(MatchLevel.Strict, sessionResults.ActualAppOutput[1].ImageMatchSettings.MatchLevel, browserInfo); Assert.AreEqual(AccessibilityLevel.AA, sessionResults.ActualAppOutput[2].ImageMatchSettings.AccessibilitySettings.Level, browserInfo); Assert.AreEqual(AccessibilityGuidelinesVersion.WCAG_2_0, sessionResults.ActualAppOutput[2].ImageMatchSettings.AccessibilitySettings.GuidelinesVersion, browserInfo); Assert.IsTrue(sessionResults.ActualAppOutput[2].ImageMatchSettings.IgnoreDisplacements, browserInfo); Assert.AreEqual(MatchLevel.Layout2, sessionResults.ActualAppOutput[2].ImageMatchSettings.MatchLevel, browserInfo); } finally { driver.Quit(); } }
public void Teardown() { Eyes?.CloseAsync(); But?.Quit(); _runner.GetAllTestResults(); //TODO Do something with this? }