We have released a Java SDK that simplifies the integration of the Applitools Eyes cloud service with any Java based test framework (mobile, desktop or web).
You can enjoy the full benefits of automated visual testing simply by providing the SDK with screenshots of your application.Note: Selenium and Appium Java users should continue to use the Selenium Java SDK which is tailored for these frameworks.
The new SDK can be obtained from Maven using the following dependency:
<dependency> <groupId>com.applitools</groupId> <artifactId>eyes-images-java3</artifactId> <version>RELEASE</version> </dependency>The test below is a sample automated visual test which uses the SDK to validate 2 pages of a test webpage.
eyes.checkWindow method takes a raw image and is independent of any test framework.
addMouseTrigger and addTextTrigger are optional parameters that can be used to specify user actions (will make test playback look nicer).
eyes.setAppEnvironment is used to define the environment that is used to run the test (OS and hosting application), and ensure that a unique baseline will be created for each environment and any consequent tests will be compared against the right baseline.
import com.applitools.eyes.images.*; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; public class SimpleTest { public static void main(String[] args) throws IOException, URISyntaxException { Eyes.setApiKey("Your API Key"); Eyes.setLogHandler(new StdoutLogHandler(true)); Eyes eyes = new Eyes(); // Define the OS and hosting application to identify the baseline eyes.setAppEnvironment("Windows7", "My chrome browser"); BufferedImage img; try { eyes.open("My Website", "Sanity Test", new RectangleSize(1024, 768)); // Load home page image and validate img = ImageIO.read(new File("C:\\Users\\home.png")); eyes.checkWindow(img, "Home Page", false); // Simulate click on the "Get button" eyes.addMouseTrigger(MouseAction.Click, new Region(579, 549, 221, 62), new Location(5, 5)); // Load the page and validate img = ImageIO.read(new File("C:\\Users\\get_page.png")); eyes.checkWindow(img, "Get", false); // Finish the test eyes.close(); } finally { eyes.abortIfNotClosed(); } } }
Comments
0 comments
Article is closed for comments.