Android Automation

Occasionally the target Android application has a complex or unique workflow that requires more sophisticated automation control. Default UI automation in Lab uses a heuristic-based approach to detect common UI elements, e.g., login, password, registration forms. It may be necessary to write a custom UI automation script to achieve better coverage of your application.

Here’s a boiler-plate interaction script to begin with, for example Twitter for Android:

{
  "automation_steps": [
          {
            "action": "Sleep",
            "timeInMsToSleep": 10000
          },
          {
            "action": "Click",
            "clickItemMatching": "Log In"
          },
          {
            "action": "Sleep",
            "timeInMsToSleep": 10000
          },
          {
            "action": "EnterText",
            "matchStrings":       [ "username" ],
            "textToEnter"         : "ENTER_YOUR_EMAIL_OR_USERNAME_HERE",
            "fieldType"           : "username"
          },
          {
            "action": "EnterText",
            "matchStrings":       [ "password" ],
            "textToEnter"         : "ENTER_YOUR_PASSWORD_HERE",
            "fieldType"           : "password"
          },
          {
            "action": "Sleep",
            "timeInMsToSleep": 10000
          },
          {
            "action": "Click",
            "clickItemMatching": "Log In"
          }
  ]
}
  1. Delay 10 seconds to allow the app to finish loading and for the login screen to appear

  2. We wrap the rest of our script to ensure the login UI elements are on the screen. If we don’t, UI

  3. automation will error because the elements are not present.

  4. The automator will click the “Log In” button.

  5. Have the automator type the USERNAME OR EMAIL and the PASSWORD into the appropriate fields.

  6. The automator will finally click the “Log In” button and, hopefully, login to the account associated with that Android application.