This article will explain:
How to use the Applitools Eyes SDK for adding visual validation to your Selenium Java 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 Java:
import com.applitools.eyes.Eyes;
import com.applitools.eyes.RectangleSize;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.net.URISyntaxException;
public class TempiTest {
public static void main(String[] args) throws URISyntaxException,
InterruptedException
{
WebDriver driver = new FirefoxDriver();
// Use your own api key, make sure you use it in all your tests.
Eyes eyes = new Eyes();
eyes.setApiKey("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
RectangleSize(1024, 768));
driver.get("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();
}
}
}
Comments
0 comments
Article is closed for comments.