This article will explain:
- How to use the Applitools Eyes SDK for adding visual validation to your CodedUI tests.
Using the Applitools Eyes SDK involves 4 main steps:
1. Create and config an Eyes object.
2. Start a test.
3. Add UI validation check points.
4. Close the test.
The example below illustrates how to build a visual test with Microsoft CodedUI:
using Applitools; public void TestApplitoolsWebsite() { // Use your own api key here, make sure you use it in all your tests. Eyes.ApiKey = "your api key"; Eyes.SetLogHandler(new StdoutLogHandler(true)); var eyes = new Eyes(); #region Variable Declarations BrowserWindow uIBlankPageWindowsInteWindow = this.UIBlankPageWindowsInteWindow; HtmlHyperlink uIFeaturesHyperlink = this.UIBlankPageWindowsInteWindow.UIApplitoolsVisualTestDocument.UIFeaturesCustom.UIFeaturesHyperlink; #endregion // Go to web page 'http://applitools.com/' UIBlankPageWindowsInteWindow.LaunchUrl(new System.Uri(this.ApplitoolsMethodParams.UIBlankPageWindowsInteWindowUrl)); try { // Start visual testing with browser viewport set to 1024x768. // Make sure to use the returned driver from this point on. // Note that the AUT must be launched before eyes.open command eyes.Open(UIMap.UIBlankPageWindowsInteWindow, "Applitools", "Test Web Page", new System.Drawing.Size(1024, 768)); // Visual validation point #1 eyes.CheckWindow("Home Page"); Mouse.Click(uIFeaturesHyperlink, new Point(25, 26)); // Visual validation point #2 eyes.CheckWindow("Features Page"); // End visual testing. Validate visual correctness. eyes.Close(); } finally { // Abort test in case of an unexpected error. eyes.AbortIfNotClosed(); }