public static void Main(string[] args) { var eyes = new Eyes(); // Note 1 eyes.ApiKey = Environment.GetEnvironmentVariable("MY_APPLITOOLS_API_KEY"); // Note 2 var innerDriver = new ChromeDriver(); // Note 3 var viewportSize = new Size(1024, 768); var driver = eyes.Open(innerDriver, "My Application Name", "My Test Name", viewportSize); // Note 4 try { string website = "https://applitools.com/helloworld"; driver.Url = website; // Note 5 eyes.CheckWindow("initial screen"); // Note 6 Applitools.TestResults result = eyes.Close(false); // Note 7 } catch (Exception ex) { } finally { // If the test was aborted before eyes.Close was called, ends the test as aborted. eyes.AbortIfNotClosed(); // Note 8 } innerDriver.Quit(); // Note 9 }
public static void Main(string[] args) { var eyes = new Eyes(new Uri("https://testeyesapi.applitools.com")); // Note 1 eyes.ApiKey = Environment.GetEnvironmentVariable("APPLITOOLS_TESTAPI_KEY"); // Note 2 eyes.ApiKey = "qYQ6SVJh105wOsguQnXFzkuRHEndcUnYsIKvLqUxEVTho110"; var innerDriver = new ChromeDriver(); // Note 3 var viewportSize = new Size(1024, 768); var driver = eyes.Open(innerDriver, "Demos", "Domain Diff 16", viewportSize); // Note 4 eyes.SendDom = true; try { /*string website = "https://applitools.com/helloworld";*/ string diff = "?diff3"; string website = "C:/Users/User/Documents/eyes-knowledgebase-source/FlareProjects/Content/example-code/HelloWorldDomDiffs/helloworlddomdiffs.html"; website += diff; driver.Url = website; // Note 5 eyes.CheckWindow("initial screen"); // Note 6 Applitools.TestResults result = eyes.Close(false); // Note 7 } catch (Exception ex) { var i = 1; } finally { // If the test was aborted before eyes.Close was called, ends the test as aborted. eyes.AbortIfNotClosed(); // Note 8 } innerDriver.Quit(); // Note 9 }
private void LogApplitools() { if (eyes != null && Test != null) { var throwtTestCompleteException = false; Applitools.TestResults result = eyes.Close(throwtTestCompleteException); string url = result.Url; if (result.IsNew) { Test.Log(Status.Info, "New Baseline Created: URL=" + url); } else if (result.IsPassed) { Test.Log(Status.Info, "Visual check Passed: URL=" + url); } else { Test.Log(Status.Info, "Visual check Failed: URL=" + url); } } }
public static void Main(string[] args) { // Initialize the eyes SDK and set your private API key. var serverURL = new Uri("https://eyesapi.applitools.com"); // %%%% start set-baseline-env var eyes = new Eyes(serverURL); // %%%% stop set-baseline-env eyes.ApiKey = Environment.GetEnvironmentVariable("APPLITOOLS_API_KEY"); // Open a Chrome browser. var innerDriver = new ChromeDriver(); var viewportSize = new Size(1024, 768); // Start the test and set the browser's viewport size eyes.SetAppEnvironment("Windows 10", "Firefox"); // %%%% start set-baseline-env eyes.BaselineEnvName = "desktop browser"; //now call open // %%%% stop set-baseline-env // %%%% start set-matchlevel eyes.MatchLevel = Applitools.MatchLevel.Layout; // %%%% stop set-matchlevel var driver = eyes.Open(innerDriver, "cross environment", "test 1", viewportSize); // %%%% stop set-baseline-env try { // Navigate the browser to the "hello world!" web-site. string website = "https://applitools.com/helloworld"; driver.Url = website; // Visual checkpoint #1 eyes.CheckWindow("Before mouse click"); // Click the "Click me!" button. driver.FindElement(By.TagName("button")).Click(); // Visual checkpoint #2. eyes.CheckWindow("After mouse click"); // End the test var throwtTestCompleteException = false; Applitools.TestResults result = eyes.Close(throwtTestCompleteException); string url = result.Url; if (result.IsNew) { Console.WriteLine("New Baseline Created: URL=" + url); } else if (result.IsPassed) { Console.WriteLine("All steps passed: URL=" + url); } else { Console.WriteLine("Test Failed: URL=" + url); } } catch (Exception ex) { Console.WriteLine(ex); } finally { // If the test was aborted before eyes.Close was called, ends the test as aborted. eyes.AbortIfNotClosed(); } // Close the browser. innerDriver.Quit(); }
public static void Main() { // Open a Chrome browser. var driver = new ChromeDriver(); // Initialize the eyes SDK and set your private API key. var eyes = new Eyes(); eyes.ApiKey = "Applitools_ApiKey"; try { // Start the test and set the browser's viewport size to 800x600. eyes.Open(driver, "Hello World!", "My first Selenium C# test!", new Size(800, 600)); // Navigate the browser to the "hello world!" web-site. driver.Url = "https://applitools.com/helloworld"; // Visual checkpoint #1. eyes.CheckWindow("Hello!"); //Click the "Click me!" button. driver.FindElement(By.TagName("button")).Click(); //Visual checkpoint #2. eyes.CheckWindow("click!"); // End visual testing. Validate visual correctness. Applitools.TestResults result = eyes.Close(false); //Link to batch result. Console.WriteLine(String.Format("This is the link for the Batch Result: {0}", result.Url)); ApplitoolsTestResultsHandler.ApplitoolsTestResultsHandler testResultHandler = new ApplitoolsTestResultsHandler.ApplitoolsTestResultsHandler("Applitools_ViewKey", result); //Optional Setting this prefix will determine the structure of the repository for the downloaded testResultHandler.setPathPrefixStructure("TestName/AppName/viewport/hostingOS/hostingApp"); // Download both the Baseline and the Current images to the folder specified in Path. testResultHandler.downloadImages("PathToDownloadImages"); // Download the Current images to the folder specified in Path. testResultHandler.downloadCurrentImages("PathToDownloadImages"); // Download the Baseline images to the folder specified in Path. testResultHandler.downloadBaselineImages("PathToDownloadImages"); // Download Diffs to the folder specified in Path. testResultHandler.downloadDiffs("PathToDownloadImages"); } catch (Exception ex) { Console.WriteLine(ex); } finally { // Close the browser. driver.Quit(); // If the test was aborted before eyes.Close was called, ends the test as aborted. eyes.AbortIfNotClosed(); } }