Here Just required only three files which all are need
to placed in the root folder of our
MonkeyTalk application.
1. Code Script for MonkeyTalk. This is the
one way where we do all that automation code.
2. Data driver script. This script will be
used run to execute the test scenarios. This script will call the main code
script of MonkeyTalk and it will pass a csv file (with comma separated
value) with it. Actual action of this script as a main function in a java class
file which will be invoked first and then others will be invoked like the
thread of main function progresses.
3. CSV file always contains all the parameters
that we want to pass for all variables in the data driven script. The order of.
Main code script for MonkeyTalk (or the driven script) in MonkeyTalk form is:-
Vars * Define by user pass
Input user_name Tap
Input user_name EnterText ${user}
Input password EnterText ${pass}
Button LOGIN Verify LOGIN %thinktime=2000
Button LOGIN Tap
Label * Verify "Welcome, ${user}!" %thinktime=4000
Button LOGOUT VerifyNot LOGIN
Button LOGOUT Tap %thinktime=6000
Data Driver Script for MonkeyTalk form:-
Script
<name_of_driven_script>.mt RunWith <name_of_csv_file>.csv
CSV file like:-
user
pass1
user
name1, pasword1
user
name2, pasword2
user
name3, pasword3
You will Notice that the first row of CSV file is the
variable name and the contents of second line have the values in variables.
Iterations: The iteration of script is depending on
the number of rows available in csv file. By this way script will run 3 times. First
iteration will pass the first row values and then next iteration will pass the
next value.
Variable introduction: Variables are initialized or
not, it does not matter in the driven script. If you have initialized some
values to declare then that value will be fetched for that variable during the
first iteration and the new value as assigned in the script will be delivered
to the variable. It is based on the assumption of variable which declared in
the variable as mentioned in the coded script.
Do I require state all the variables in the csv file even
if I don’t desire to alter their worth in each iteration? No, You not
required. Just mention only that variable which is required to iterate in every
iteration.
Blank value leaving for a var in csv file: If your
will left the variable value as blank the that will be 0 and none will be
assigned to variable(technically, null). Even if in the second iteration the
variable will not hold the value provided to it in the first step. It means
that var is washed off even when there are not any values to be assigned to it for
second Step.
Note: Confirm that we will hit the run or play button
when we are using browsing the driver script and not the driven script.
Javascript form for Monkey Script:-
load("libs/<monkey_project_name>.js");
<monkey_project_name>.<driven_script_name>.prototype.run
= function(user, pass) {
this.app.input("user_name").tap();
this.app.input("user_name").enterText(user);
this.app.input("pass_word").enterText(pass);
this.app.button("LOGIN").verify("LOGIN", {thinktime:"2000"});
this.app.button("LOGIN").tap();
this.app.label().verify("Welcome, " + user + "!",
{thinktime:"4000"});
this.app.button("LOGOUT").verifyNot("LOGIN");
this.app.button("LOGOUT").tap({thinktime:"6000"});
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
No comments:
Post a Comment