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.
MonkeyTalk form:-
Driven script
Vars * Define pass user
Input username EnterText ${user}
Input password EnterText ${pass}
Button LOGIN Tap %thinktime=500
Button LOGOUT Tap %thinktime=3000
Driver Script
Script <driven_script_name>.mt Run username1
"password1"
Script <driven_script_name>.mt Run username2
"password2" %thinktime=3000
Test message
Javascript
form:
Driven script
load("libs/<monkey_talk_project_name>.js");
<monkey_talk_project_name>.<driven_script_name>.prototype.run
= function(pass, user) {
this.app.input("username").enterText(user);
this.app.input("password").enterText(pass);
this.app.button("LOGIN").${empty}({thinktime:"500"});
this.app.button("LOGOUT").${empty}({thinktime:"3000"});
};
Driver script
load("libs/<monkey_talk_project_name>.js");
<monkey_talk_project_name>.<driver_script_name>.prototype.run
= function() {
this.app.<dri>().run("john1",
"password1");
this.app.gj1().run("john2",
"password2", {thinktime:"3000"});
};
Think Time at the end of second line of the driver
script is important because when a script is executed the second time
the first script needs some time to process the logout operation before
starting the second script. Likewise, we can also provide a think time to the
first script if it were to be followed by a test setup method/script while
requires some processing.
Order of variables: It can be observed that in
the driven script the password variable is declared first followed by the
username variable. So all the values passed in as the first argument in the
driver script are assigned to the pass variable. Although one might want to
believe that since user variable is used first in the script the first value
passed as argument would be the assigned to user, that is NOT correct.
Variables values that contain spaces can also
be passed using the driven script. To prevent the space within the variable
value from being interpreted as a separator between two arguments, one has to
pass the argument within double quotes. For example: one can pass a password as
“this is my password”
nice share guys
ReplyDeletekeep posting
I LIKE IT THANKS BEFORE Life Style
I would like to thank you for sharing this great information with us. I am really glad to learn about this because it helps me to increase my knowledge.Web Designing Company | Website Design Company
ReplyDeleteOnline Casino Site ᐈ Best Payout Casinos 2021
ReplyDeleteOnline Casino Sites — What Makes Online Casino Site Different from 카지노 Any Other Casino Site? — There are a number of different casino sites to choose 온카지노 from 샌즈카지노