Visual Testing With Applitools and KOBITON

Reading Time : 4min read
Visual Testing with Applitools and KOBITON

APPLITOOLS Overview

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 Overview

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.

How to obtain your Applitools API key

To run visual UI tests using Eyes, you need to obtain an API Key. You can do so as follows:

  1. If you don’t have an Eyes account yet, you can create a free account and skip to step 3.
  2. If you already have an Eyes account, then login to eyes.applitools.com or to your dedicated cloud.
  3. Click on the main menu icon  at the top right of the window and choose the “My API Key” option. Your key will be displayed and selected.

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.

How to get your Kobiton API key

To run automation tests with Kobiton, you also need an API Key. You can get the key by the following steps:

  1. If you don’t have a Kobiton account yet, you can create a free account.
  2. If you have a Kobiton account, then access to https://portal.kobiton.wpengine.com/settings/keys to get API Key.

Appium Native Java Tutorial

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.

Install the SDK

<dependency>

<groupId>com.applitools</groupId>

<artifactId>eyes-appium-java4</artifactId>

<version>RELEASE</version>

</dependency>

Run your first test

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();

}

}

}

Analyze your test results

  • Congratulations! You’ve successfully run your first visual UI test with Applitools Eyes! A detailed report is ready for your inspection at the Applitools Eyes test manager.
Applitools visual testing with appium and kobiton
Applitools eyes test manager detailed report of Appium native java test
  • In addition, the automation test session is also created on the Kobiton system. You can access to the Sessions page to get more info.
Visual testing session overview hybrid application

Interested in Learning More?

Subscribe today to stay informed and get regular updates from Kobiton

Ready to accelerate delivery of
your mobile apps?

Request a Demo