Getting Started with Espresso Testing

Support for Android's Espresso automated testing framework allows users to run Espresso testing scripts on Kobiton devices with minimal setup.

On the Kobiton UI, automation setting will return the information needed to connect to Android devices and run an Espresso test from your testing environment. 

Espresso Automation Settings

To retrieve the setting needed to run an Espresso Test: 

  1. On the Kobiton portal, navigate to the desired Android device and click on the ellipses icon vertical-ellipses-icon.png
  2. Click on Automation Settings
  3. Fill in the following testing capabilities (is that what they are called for Expresso)
    • Framework: select UIAutomator/ Espresso
    • Language: (Java, .Net C#, NodeJS, Ruby, Python, PHP)
    • Session Name: By default, "Automation test session" is set, but the name can be customized
    • Description: Optional session description
    • Session Timeout: By default set to 60 minutes, but can be changed to designated time
    • Test Timeout: By default set to 0 minutes, but can be changed to designated time
    • User Group: Set by default, but can be changed if part of multiple groups
    • Device Group: Set by default, but click to open the dropdown for other available groups
    • Use specific device: enable to use the specified Android device only
    • Continue on failure: enable to continue testing
    • App: Either upload an application with a URL or an application on the Kobiton App Repository:
      • Hybrid/Native from URL
      • Hybrid/Native from Apps
    • Test Runner:  Enter the URL for the test.apk or use click Upload Test Runner to upload a test.apk file 
    • API Key: Default API key
  4. Use the copy to clipboard icon to copy the generated desired capabilities to your testing files. espresso-test-settings.png
  5. Add the copied capabilities to the configuration on your test script (settings with comments removed):

const username = 'kobiton.username'
const apiKey = 'dd13c1-6124-5223-9b8a-51e01b41263e'
const configuration = {
sessionName:'Espresso automation test session',
sessionDescription:'Espresso testing example',
deviceName:'Galaxy A20',
platformVersion:'9',
groupId:905,
deviceGroup:'KOBITON',
app:'https://kobiton-devvn.s3-ap-southeast-1.amazonaws.com/apps-test/uiautomator-espresso/espresso-app.apk',
testRunner:'https://kobiton-devvn.s3-ap-southeast-1.amazonaws.com/apps-test/uiautomator-espresso/esspresso-test-runner.apk',
continueOnFailure:true,
testFramework:'UIAUTOMATOR'
};

Example: 

The JavaScript Espresso testing example will make a connection to a public Android device through the Kobiton portal. To view this project on Github, click here

const request = require("request");

const username = "kobiton.username";
const apiKey = "dd21c1-6124-5223-9b8a-51e01b41263e";

const encodeAuth = `Basic ${Buffer.from(`${username}:${apiKey}`).toString('base64')}`;

const configuration = {
sessionName:"Espresso automation test session",
sessionDescription:"Espresso testing example",
deviceName:"Galaxy A20",
platformVersion:"9",
groupId:905,
deviceGroup:"KOBITON",
app:"https://kobiton-devvn.s3-ap-southeast-1.amazonaws.com/apps-test/uiautomator-espresso/espresso-app.apk",
testRunner:"https://kobiton-devvn.s3-ap-southeast-1.amazonaws.com/apps-test/uiautomator-espresso/esspresso-test-runner.apk",
continueOnFailure:true,
testFramework:"UIAUTOMATOR"
};

const headers = {
'Content-Type':'application/json',
'Authorization':encodeAuth,
'Accept':'application/json'
};

constbody = {
configuration
};

request ({
url:"https://api.kobiton.com/hub/session",
json:true,
method:'POST',
body,
headers
},

function (err, response, body) {
if (err) returnconsole.error ("Error:", err);
console.log('Response body:', body);
});

Play the video to watch what to expect from this test sample:

 

Was this article helpful?
0 out of 0 found this helpful