Passing variable values through driver script in MonkeyTalk



Passing variable values through driver script in MonkeyTalk

Variables Values can be passed as parameters in a driver script. The condition is only that these should be granted in the similar order as they are assigned. You have two scripts here one is related to the main code (the driven) script and another one is the driver script.

Form for MonkeyTalk:-
Driven script
Vars * Define pass user
Input user_name  EnterText ${_user}
Input password EnterText ${_pass}
Button LOGIN Tap %thinktime=600
Button LOGOUT Tap %thinktime=4000

The Driver Script
Script <driven_script_name>.mt Run user_name1 "password1"
Script <driven_script_name>.mt Run user_name2 "password2" %thinktime=3000
Test message

JavaScript form for Driven script
load("libs/<monkey_talk_project_name>.js");
<monkey_talk_project_name>.<driven_script_name>.prototype.run = function(pwd, UD) {
                this.app.input("user_name ").enterText(usser);
                this.app.input("password1").enterText(paass);
                this.app.button("LOGIN").${empty}({thinktime:"500"});
                this.app.button("LOGOUT").${empty}({thinktime:"3000"});
};

Driver script
load("libs/<monkey_talk_project1_name>.js");
<monkey_talk_project_name>.<driver_script_name>.prototype.run = function() {
                this.app.<dri>().run("mary1", "password1");
                this.app.gj1().run("jeff2", "password2", {thinktime:"4000"});
};

In Driver Script Think Time available at the end of second line is essential because when a script is executed the 2nd time then first script requires a little time to process the logout process before starting the 2nd script. Similarly, you can also offer a think time to the 1st script if it were to be followed by the test setup method / script while requires some processing.

Variables Ordering: It can be watched that in the driven script variable is the password declared then 1st it will followed by the user_name variable. So all the values passed in as the 1st parameter in the driver script are allocated to pass the variable. Even though one might desire to trust that since user variable is used first in the script the first value passed as argument that would be the assigned to user, that will not NOT be correct.

Variables values which have spaces can also be passed using the driven script. To avoid the space within the variable value from being interpreted as a divider between two parameters, one has to pass the parameter within dual quotes. As a example: one can pass his password like “Personal password”.


Emulator should be already in executable state while installing any Apps in Emulator



No comments:

Post a Comment

Popular Posts