public static void Test1(IWebDriver webDriver, Eyes eyes) { try { // V1 URL //webDriver.Url = "https://demo.applitools.com/tlcHackathonMasterV1.html"; // Dev URL // webDriver.Url = "https://demo.applitools.com/tlcHackathonDev.html"; // V2 URL webDriver.Url = "https://demo.applitools.com/tlcHackathonMasterV2.html"; // Call Open on eyes to initialize a test session eyes.Open(webDriver, "AppliFashion", "Test 1", new RectangleSize(1200, 800)); eyes.Check(Target.Window().Fully().WithName("main page")); eyes.CloseAsync(); } catch (Exception e) { eyes.AbortAsync(); } }
public static void Test2(IWebDriver webDriver, Eyes eyes) { try { // V1 URL //webDriver.Url = "https://demo.applitools.com/tlcHackathonMasterV1.html"; // Dev URL // webDriver.Url = "https://demo.applitools.com/tlcHackathonDev.html"; // V2 URL webDriver.Url = "https://demo.applitools.com/tlcHackathonMasterV2.html"; // Call Open on eyes to initialize a test session eyes.Open(webDriver, "AppliFashion", "Test 2", new Size(1200, 800)); webDriver.FindElement(By.XPath("//label[text()='Black ']")).Click(); webDriver.FindElement(By.Id("filterBtn")).Click(); Thread.Sleep(3000); eyes.CheckRegion(By.Id("product_grid"), "filter by color", 3); eyes.CloseAsync(); } catch (Exception e) { eyes.AbortAsync(); } }
private static void TestDemoApp(IWebDriver driver, Eyes eyes) { try { // Set AUT's name, test name and viewport size (width X height) // We have set it to 800 x 600 to accommodate various screens. Feel free to // change it. eyes.Open(driver, "Demo App", "Smoke Test", new Size(800, 600)); // Navigate the browser to the "ACME" demo app. driver.Url = "https://demo.applitools.com"; // To see visual bugs after the first run, use the commented line below instead. // driver.get("https://demo.applitools.com/index_v2.html"); // Visual checkpoint #1 - Check the login page. using the fluent API // https://applitools.com/docs/topics/sdk/the-eyes-sdk-check-fluent-api.html?Highlight=fluent%20api eyes.Check(Target.Window().Fully().WithName("Login Window")); // This will create a test with two test steps. driver.FindElement(By.Id("log-in")).Click(); // Visual checkpoint #2 - Check the app page. eyes.Check(Target.Window().Fully().WithName("App Window")); // End the test. eyes.CloseAsync(); } catch (Exception e) { // If the test was aborted before eyes.close was called, ends the test as // aborted. eyes.AbortAsync(); } }
public static void Test3(IWebDriver webDriver, Eyes eyes) { try { // V1 URL // webDriver.Url = "https://demo.applitools.com/tlcHackathonMasterV1.html"; // Dev URL // webDriver.Url = "https://demo.applitools.com/tlcHackathonDev.html"; // V2 URL webDriver.Url = "https://demo.applitools.com/tlcHackathonMasterV2.html"; // Call Open on eyes to initialize a test session eyes.Open(webDriver, "AppliFashion", "Test 3", new Size(1200, 800)); webDriver.FindElement(By.XPath("//img[@alt='Appli Air x Night']")).Click(); Thread.Sleep(3000); eyes.Check(Target.Window().Fully().WithName("product details")); eyes.CloseAsync(); } catch (Exception e) { eyes.AbortAsync(); } }
public void Task3() { VisualGridRunner runner = new VisualGridRunner(10); Eyes eyes = new Eyes(runner); try { SetUp(eyes); eyes.Open(_driver, "AppliFashion", "Task3", new Size(800, 600)); _driver.Click(page.HomePage.ProductGridFilterIcon); _driver.SetValue(page.HomePage.SidebarGridFilterOption("Black"), "true"); _driver.Click(page.HomePage.SidebarGridFilterFilterButton); _driver.Click(page.HomePage.ProductGridProductCard("Appli Air x Night")); Assert.IsTrue(page.ProductPage.IsAt()); Assert.IsTrue(_driver.Displayed(page.ProductPage.ProductImage)); eyes.Check(Target.Window().Fully().WithName("Product Details test")); } catch { eyes.AbortAsync(); } finally { TearDown(_driver, runner); } }
public void TearDown() { try { driver.Quit(); eyes.CloseAsync(); } finally { eyes.AbortAsync(); } }
public void TestSuccess() { ILogHandler logHandler = TestUtils.InitLogHandler(); VisualGridRunner visualGridRunner = new VisualGridRunner(10, logHandler); Size[] ViewportList = { new Size(800, 600), new Size(700, 500), new Size(1200, 800), new Size(1600, 1200) }; IWebDriver webDriver = SeleniumUtils.CreateChromeDriver(); webDriver.Url = "https://applitools.com/helloworld"; try { foreach (Size viewport in ViewportList) { Eyes eyes = InitEyes_(null, webDriver, viewport); eyes.Check(Target.Window().Fully()); eyes.CloseAsync(); try { eyes = InitEyes_(visualGridRunner, webDriver, viewport); eyes.Check(Target.Window().Fully()); eyes.CloseAsync(); } finally { eyes.AbortAsync(); } } TestResultsSummary results = visualGridRunner.GetAllTestResults(); Assert.AreEqual(ViewportList.Length, results?.Count); } finally { webDriver?.Quit(); } }
public void Task1() { VisualGridRunner runner = new VisualGridRunner(10); Eyes eyes = new Eyes(runner); try { SetUp(eyes); eyes.Open(_driver, "AppliFashion", "Task1", new Size(800, 600)); eyes.Check(Target.Window().Fully().WithName("Cross-Device Elements Test")); } catch { eyes.AbortAsync(); } finally { TearDown(_driver, runner); } }
public void Task2() { VisualGridRunner runner = new VisualGridRunner(10); Eyes eyes = new Eyes(runner); try { SetUp(eyes); eyes.Open(_driver, "AppliFashion", "Task2", new Size(800, 600)); _driver.Click(page.HomePage.ProductGridFilterIcon); _driver.SetValue(page.HomePage.SidebarGridFilterOption("Black"), "true"); _driver.Click(page.HomePage.SidebarGridFilterFilterButton); eyes.Check(Target.Region(page.HomePage.ProductGrid).WithName("Filter Results")); } catch { eyes.AbortAsync(); } finally { TearDown(_driver, runner); } }
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 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 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); }