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.
Script examples:
1. Simple Login script Click here
2. Data driven script Click here
3. Passing variables script Click here
4. Conditional statement script Click here
Script examples:
1. Simple Login script Click here
2. Data driven script Click here
3. Passing variables script Click here
4. Conditional statement script Click here
Wow,great post.
ReplyDeleteWriting scripts in MonkeyTalk allows for efficient automation of mobile application testing. This powerful tool enables developers to ensure their apps function correctly across different devices. Just like tsoHost provides a reliable hosting environment, using MonkeyTalk enhances your testing process, ensuring your application performs flawlessly.
ReplyDelete