Writing script in MonkeyTalk
Before we
start writing scripts let us understand the syntax of MonkeyTalk’s scripting
language
Syntax:
The entire
info given below is sourced from (Source):
http://www.gorillalogic.com/testing-tools/monkeytalk/documentation/monkeytalk-spec/command-syntax
MonkeyTalk
commands are newline terminated and have the following syntax:
ComponentType MonkeyId
Action Args… Modifiers…
ComponentType
(required) – The type of component on which to perform the action. Examples
include Button and TextArea. Component types are not case sensitive.
ComponentTypes can extend other ComponentTypes, as described below, and inherit
any defined actions as well as Arguments. ComponentTypes are typically the
logical name of the UI component (like Button rather than UIButton), but can
also have platform-specific aliases. All
UI components inherit from the View component type, and so specifying View on a
command is like specifying a wildcard that will match any component type.
For example:
# Tap on any
component labeled "OK"
View OK Tap
MonkeyId
(required) - An identifier that is used to distinguish between components of
the same type being displayed simultaneously. MonkeyId can be specified as
asterisk (*), which finds the first matching component.
MonkeyId’s
can also be specified as a 1-based (not zero-based) index of the form #N. In
this case, the MonkeyId identifies the Nth component of the specified type
that’s currently displayed. Components are indexed according to upper-left-most
position, i.e., by sorting components by (x,y) coordinate.
Action
(required) – The action to be performed. Examples include Tap, Select, and
EnterText. Actions are not case sensitive.
Arguments/Args
(required according to ComponentType and Action) – A space-separated list of
one or more arguments. Arguments are assumed to begin at the fourth token.
Although always specified as strings, args are interpreted as necessary by the
command. If an Argument is required but not specified (left off the end of the
list), it takes on a default value. An Arg may be specified as an asterisk (*)
to force it to take on it’s default value,
Modifiers…
(optional) - A space-separated list of named arguments of the form %name=value,
where the % prefix identifies it as a Modifier. There are three system-defined
modifiers:
%timeout -
how long in ms to continue retrying a command before timing out
%thinktime -
how long in ms to wait before executing the command for the first time
%retrydelay
- how long in ms to delay between retry attempts
Once you
install the MonkeyTalk IDE and the make the necessary changes to the source
code of the app provided by the developer, you can connect the MonkeyTalk to
the emulator/device that app is installed on and you can start writing scripts.
It is
suggested that before writing scripts one should record multiple actions on the
app and let monkey record (write) the script for you. This way one can learn
which action is related to which command.
A MonkeyTalk
script can write in three forms:-
- Table View
- MonkeyTalk script
- Javascript
These are
just three different representations of same script. In the background both
these run in exact same manner.
Related Articles:-
- Eclipse configuration with Android SDK (Click here…)
- Monkey Talk: Installation of Agent (Click here…)
- Simple Login Script (Click here…)
- Data driven Script (Click here…)
- Passing variable values through driver script (Click here...)
- Conditional statements (Click here…)
- Steps to install Android Apps to SD Card (Click here…)
- Steps to install Android App in Emulator (Click here…)
Comments
Post a Comment