ITA Gets Smarter: Added App Support, More Visual Verification, and More
Adam Creamer
Applitools has 40+ SDKs for different programming languages and test runners, covering web apps, mobile apps, screenshot testing, PDF validations, and more. Applitools is enabling teams to validate user interface (UI) components by creating automated tests with visual checkpoints through testing frameworks like Selenium, Appium, Espresso, and more.
Kobiton is a mobile testing platform that accelerates delivery and testing of mobile apps by offering manual and automated testing on real devices, in the cloud or on-premise. With Kobiton, you get instant access to over 350 real-devices, along with your own private cloud or local lab. Run manual or automated tests, manage your own enterprise device lab or get an instant health-check for your app.
To run visual UI tests using Eyes, you need to obtain an API Key. You can do so as follows:
If you assign the key to an environment variable called APPLITOOLS_API_KEY then the SDK automatically uses its value, and you don’t need to configure it in the test.
To run automation tests with Kobiton, you also need an API Key. You can get the key by the following steps:
The setup of Applitools is simple. Today, I will select Appium Native Java to install Applitools SDK. The Applitools Eyes Appium Java SDK allows you to easily add visual checkpoints to your Java Appium tests. It takes care of getting screenshots of your application from the underlying WebDriver, sending them to the Eyes server for validation, and failing the test in case differences are found.
<dependency>
<groupId>com.applitools</groupId>
<artifactId>eyes-appium-java4</artifactId>
<version>RELEASE</version>
</dependency>
According to Applitools, Applitools Eyes reports differences by comparing screenshots of your application with baseline images that define the expected appearance of the application at each step of the test. By default, the Eyes SDK detects the environment in which the application is running (namely, the operating system, the type of browser, and its viewport size) and compares the screenshots against baseline images that are specific to that environment. The first time you run a test in a given environment, its screenshots will be automatically saved as its baseline. Starting from the second run onward, you always have a baseline to compare against.
Before running the test, make sure to set the API key in eyes.setApiKey
and Kobiton server information in USERNAME:KOBITON_API_KEY correctly. After that, you can specify the Android device that you want to run the test on Kobiton by changing the deviceName on this capability setCapability(“deviceName”, “DEVICE_NAME”);.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.android.AndroidDriver;
import java.net.URL;
import com.applitools.eyes.appium.Eyes;
public class Appium_native_java {
public static void main(String[] args) throws Exception {
// Set desired capabilities.
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“platformName”, “Android”);
capabilities.setCapability(“deviceName”, “DEVICE_NAME”);
capabilities.setCapability(“deviceGroup”, “KOBITON”);
//NOTE: Download this app from https://bintray.com/applitools/Examples/Android_Demo_APK and upload it into Kobiton Store or use the public link below
capabilities.setCapability(“app”, “https://kobiton-devvn.s3-ap-southeast-1.amazonaws.com/apps-test/demo/ApplitoolsTest.apk”);
// Open the app.
WebDriver driver = new AndroidDriver(new URL(“https://USERNAME:KOBITON_API_KEY@api.kobiton.wpengine.com/wd/hub”), capabilities);
// Initialize the eyes SDK and set your private API key.
Eyes eyes = new Eyes();
eyes.setApiKey(“YOUR_API_KEY”);
eyes.setForceFullPageScreenshot(true);
try {
// Start the test.
eyes.open(driver, “Contacts!”, “My first Appium native Java test!”);
// Visual validation.
eyes.checkWindow(“Contact list!”);
// End the test.
eyes.close();
} finally {
// Close the app.
driver.quit();
// If the test was aborted before eyes.close was called, ends the test as aborted.
eyes.abortIfNotClosed();
}
}
}