MonkeyTalk Parameterized script

Posted: September 18, 2012 in Android, Automation, Monkeytalk
Tags: , , ,

MonkeyTalk Parameterized script:

Passing variable values through driver script. Value for variables can be passed as arguments in a driver script. The only requirement is that they should be provided in the same order as they are declared. We have two scripts here one is the main code (driven) script and the driver script.

In MonkeyTalk form:

# Driven script (test1.mt)

Vars * Define paswords user

Input username EnterText ${user}

Input password EnterText ${pass}

Button LOGIN Tap %thinktime=500

Button LOGOUT Tap %thinktime=3000

You can view the tabular form of driven (test1.mt) script which i have created:

# Driver Script

Script test1.mt Run john “mypassword”

Script test1.mt Run john1 “mypassword1” %thinktime=3000

Driver script in tabular form:

Parametrized script by using default  values:

# default.mt

Vars * Define username=Jyoti  password=test

Input username EnterText ${username}

Input password EnterText ${password}

Button LOGIN Tap %thinktime=3000

Label * Verify “Welcome, ${username}!” %thinktime=3000

 Result:

17:03:44.664: Started Script Playback

17:03:44.673: Vars * Define username=Jyoti pw=test

17:03:44.681: Input username EnterText jyoti

17:03:45.340: Input password EnterText test

17:03:46.004: Button LOGIN Tap %thinktime=3000

17:03:49.180: Label * Verify “Welcome, fred!” %thinktime=3000

17:03:53.327: Completed Script Playback – OK

when we send the parameters through driver script

Script default.mt Run pooja

In this case username argument will take pooja and password argument takes default value i.e. test

 Result:

17:09:05.839: Started Script Playback

17:09:05.843: Script default.mt Run pooja

17:09:05.848: Started Script Playback

17:09:05.851: Vars * Define usr=jyoti pw=test

17:09:05.855: Input username EnterText pooja

17:09:06.614: Input password EnterText test

17:09:07.088: Button LOGOUT tap %thinktime=3000

17:09:07.297: Button LOGIN Tap %thinktime=3000

17:09:10.543: Label * Verify “Welcome, pooja!” %thinktime=3000

17:09:11.158: Completed Script Playback – OK

Advertisements
Comments
  1. prabhusrinivasan says:

    i created as like two .mt files and if i click runas it showing alert as “No recent launches”.While right clicking on run as its not showing any option blankly showing run configuration option only.Further what i need to do run this script

  2. adi says:

    Hi
    I created a parameterized script.This script runs another script.The second script’s name is received as a parameter for the first script.
    My question is:
    In ant i use

    in order to run a monkeytalk script.How can i send the script name with the parameters needed in ant?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s