Visual Validations allows users to turn existing Appium scripts into functional and visual tests by configuring the following three desired capabilities included in the Appium export download:
- kobiton:visualValidation: Set to true
- ensureWebviewsHavePages: By default, set to true
- kobiton:referenceSessionId: By default kobiton:referenceSessionId will reflect the session ID for the manual session used to create the downloaded Appium export script, but this can be modified to use a different session as baseline.
Injecting and enabling these capabilities into an existing script provides support for content and layout structure validations while removing the need to script custom validations to cover a variety of test cases.
As this feature is still somewhat new and continues to be improved upon with every release, please keep in mind that at this time there are a few limitations:
- A manual session must run and the Appium session exported
- The remediation page will only display in read-only mode
- Support for Kobiton devices only (does not support Sauce Labs devices)
- Content and layout support does not include:
- crash
- color text
- WBI
- performance
Content and layout support does include text currently, with the use of the desiredCap kobiton:textValidation
To run a Visual validation on a Kobiton device:
- Download the Appium export script from the manual session.
- Open the file and navigate to: manual > src > test > java > com > kobiton > scriptlessautomation > Config.java
config.java code example
package com.kobiton.scriptlessautomation; import io.appium.java_client.remote.MobileCapabilityType; import org.apache.commons.codec.binary.Base64; import org.openqa.selenium.remote.DesiredCapabilities; public class Config { enum DEVICE_SOURCE_ENUMS {KOBITON, OTHER} public static final String KOBITON_USERNAME = "{kobiton_username}"; public static final String KOBITON_API_KEY = "{your_api_key}"; public static final String KOBITON_API_URL = "{https://your-kobiton-api-url}"; public static final String APPIUM_SERVER_URL = "https://" + KOBITON_USERNAME + ":" + KOBITON_API_KEY + "@{Kobiton-api-url}/wd/hub"; public static final DEVICE_SOURCE_ENUMS DEVICE_SOURCE = DEVICE_SOURCE_ENUMS.KOBITON; public static final int IMPLICIT_WAIT_IN_SECOND = 30; public static final int DEVICE_WAITING_MAX_TRY_TIMES = 5; public static final int DEVICE_WAITING_INTERVAL_IN_MS = 30000; public static String getBasicAuthString() { String authString = KOBITON_USERNAME + ":" + KOBITON_API_KEY; byte[] authEncBytes = Base64.encodeBase64(authString.getBytes()); String authEncString = new String(authEncBytes); return "Basic " + authEncString; } public static DesiredCapabilities getPixel3Android10DesiredCapabilities() { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("sessionName", "Automation test session"); capabilities.setCapability("sessionDescription", ""); capabilities.setCapability("deviceOrientation", "portrait"); capabilities.setCapability("noReset", false); capabilities.setCapability("fullReset", true); capabilities.setCapability("captureScreenshots", true); capabilities.setCapability("newCommandTimeout", 15 * 60); capabilities.setCapability("ensureWebviewsHavePages", true); capabilities.setCapability("kobiton:ReferenceSessionId", 111910); capabilities.setCapability("kobiton:visualValidation", true); capabilities.setCapability(MobileCapabilityType.APP, "kobiton-store:v2715"); capabilities.setCapability("deviceGroup", "KOBITON"); capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Pixel 3"); capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "10"); capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android"); return capabilities; } }
- If needed, update login credentials in public class config {}:
- In public static DesiredCapabilities get{device-information}DesiredCapabilities(), confirm the following capabilities are set true.
capabilities.setCapability("ensureWebviewsHavePages", true);
capabilities.setCapability("kobiton:visualValidation", true);
- To run the script on the same device, run the project.
Parallel Visual Validation Executions
Visual Validations can run in parallel on multiple devices, but does require additional setup.
To run Visual Validations on parallel executions:
- On config.java, add and configure the desired configuration for the additional devices.
- Navigate to manual > src > test > java > com > kobiton > scriptlessautomation > testApp.java
- Change setup(capabilities, {# of executions}); to reflect the number of parallel executions the test will run.
Example: to run two parallel executions:@Test public void [Your test function name]() throws Exception { DesiredCapabilities capabilities = Config.[Your defined desired capabilities]; findOnlineDevice(capabilities); setup(capabilities, 2); runTest(); }
- Run the project to test on the defined devices