AAIS

Overview

AAI Script (AAIS) is very simple script built on top of AAI's FindNode, it has a very simple syntax and with a dozen of commands, AAIS is not a replacement of complex JS/REST API, it is useful to write simple tests or throw away scripts. AAIS will be translated to JavaScript (and FindNode commands) during execution. It has several properties that is different from JS:

  • There is no condition, no loop, no variable, not suitable for complex scripting.
  • Any failure/error will cause the script to stop.
  • It is built to run on multiple devices in threads, users select set of devices (1 to 100), start the script.
  • Support in MDCC (multi-device control center), support of WDM (Windows desktop mode) will be available in next major version.
  • Any error messages or print output will be kept in the log file.
  • Since it is built on top of FindNode, it inherits properties of FindNode:
    • Object-based, not coordinate based.
    • Support scripts in mixed device environment (different resolution and sized).
    • Use "find" to replace device dependent page down/up. "find" will scroll until the node is found.

Next version

Several enhancements to next version:

  • "get" to obtain information from node/nodes.
  • "exec" to invoke JavaScript.

AAIS Command

click/longClick

Click or longclick on query string or text on the screen. If the query or text is not found, the script will stop. See FindNode User Guide on the query syntax.

Usage:

click/longClick <text|query>

Examples:

click "T:About phone||OX:1"
longClick "Information"

open/restart

open or restart an application, the restart will force-close the application and start again. If the application is not found, the script will stop.

Usage:

open/restart <package name>
open/restart <app name>

Examples:

open "com.raider.skype"
wait "Favorites"
restart "Skype" 

wait

The command waits until the match is found or timeout expires. If the timeout expires, the script will stop. Without the timeout specified, the default is 5000ms. See FindNode User Guide on the query syntax.

Usage:

wait <text|query>
wait <text|query>, <timeout in milliseconds>

Examples:

wait "Finish"
wait "R:.icon_done", 20000

text

Enter text into the text field, if the screen cannot find the text field, position out of bound or label cannot be found, the script will stop.

Usage:

text <text>		// Enter text in the first text field
text <text>, <position> 	// position starts with 0 – first text field, 1 – second text field, …
text <text>, <label>	// Enter into the text field with the initial label.

Examples:

text "Hello world"
text "Hello world", "Please input a message"
text "Hello world", 2

press

Press a keycode (and optional meta state) or keycode name, wrong keycode name will stop the script.

Usage:

press <keycode name>
press KeyCode, <keycode>
press KeyCode, <keycode>, <meta state>

Examples:

press Home
press KeyCode, 47, 1

Refer to https://developer.android.com/reference/android/view/KeyEvent for all the keycode names. The following are the popular keycode name (case insensitive):

Enter
Back
Home
Back_space
Search
Power
Tab

find

It will scroll down the screen until the match is found, it not found, the script will stop. The search starts from the current location and scroll down for 10 pages or end of the page.

Usage:

find <text|query>

Examples:

find "John"
find "T:OK||C:.Button"

exec

Execute another AAIS, if will stop if the script generates error. The default is on the script directory.

Usage:

exec <file path and filename>

Examples:

exec "aais\\skype.tst"
exec "C:\\aais\\skype.tst"

print

Print the text string to the log file.

Usage:

print <text>

delay

Temporary pause the execution of the script for specified milliseconds.

Usage:

delay <time in milliseconds> 

Examples:

delay 10000

AAIS Example:

open "Skype"
wait "Favorites"
print "Skype is started"
click "T:Chats||IX:-1"
find "T:Jane Tan"
click "T:Jane Tan"
text "Good morning John", "Type a message"
// Press the send button
click "TP:textInput||OX:2"
// Dismiss the keyboard
press Back
// Go back to Chats page
press Back
print "Done"

Creating Scripts

Save the scripts into a text field with ".tst" extension, e.g. skype.tst, alternatively you can use MDCC Record and Replay to record the script in AAIS (you need to select Object mode) file.

Running Scripts

Running scripts are simple:

  • Open MDCC window.
  • Select the device by thumbnail device or select a group. Main device will always be selected.
  • Click "Runner".
  • Select one or multiple scripts, when the checkbox is clicked, it will show execution orders.
  • Click Run button, it will run scripts on the devices.