Transcripted Summary
The next step in setting up to begin using visual testing is to add Eyes to your automation project.

Completing the following steps will instantiate Eyes and pass your API key to Applitools.

  1. Create an Eyes object
Eyes eyes = new Eyes();

  1. Provide Eyes with your API key
eyes.setApiKey(System.getProperty("applitools.api.key"));

Note:

REMEMBER: We have the API Key stored in our property file, so we are going to read it from there


An example of the entire class:

package base;

import com.applitools.eyes.selenium.Eyes;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;


import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;


public class BaseTests {

    protected static WebDriver driver;
    protected static Eyes eyes;

    @BeforeClass
    public static void setUp() {
        Properties props = System.getProperties();
        try {
            props.load(new FileInputStream(new File("resources/test.properties")));
        } catch(Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }

        driver = new ChromeDriver();
        initiateEyes();

        driver.get(System.getProperty("site.url"));
    }

    @AfterClass
    public static void tearDown() {
        driver.quit();
        eyes.abortIfNotClosed();
    }

    private static void initiateEyes(){
        eyes = new Eyes();
        eyes.setApiKey(System.getProperty("applitools.api.key"));
    }
}


Resources



© 2024 Applitools. All rights reserved. Terms and Conditions Privacy Policy GDPR