This article will explain:
How to use the Applitools Eyes SDK for adding visual validation to your Selenium .Net 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 Selenium .Net:
using System; using System.Drawing; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using Applitools; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { IWebDriver driver = new FirefoxDriver(); // Your api key, make sure you use it in all your tests. var eyes = new Eyes() Eyes.ApiKey = "your api key"; try { // Start visual testing with browser viewport set to 1024x768. // Make sure to use the returned driver from this point on. driver = eyes.Open(driver, "Applitools", "Test Web Page", new System.Drawing.Size(1024, 768)); driver.Navigate().GoToUrl("http://applitools.com"); // Visual validation point #1 eyes.CheckWindow("Main Page"); driver.FindElement(By.CssSelector(".features>a")).Click(); // 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(); driver.Quit(); } } } }