Monday 24 December 2012

PARAMETERIZATION IN QTP


PARAMETERIZATION IN QTP:

The process of replacing the fixed value with parameter is called parameterization.

The parameter value assigned from External resource or generator.

We use parameterization in data driven testing(Testing the same operation with multiple set of test data).


Type of parameterization

1) Datatable parameterization:

-> Its enable to create a data-driven test that runs several times using the data which one you supply.

-> In each repetation or iteration, Quick test use different values from datatable ( Either Global or Action).

-> Datatable contains two type of data sheets.

i) Global - This data sheet contains the data is available for all action.
ii)Action - This data sheet contains the data is available for only the perticular action according to the action number..

From keyword view

item         operation      value

q            set            "QTP"      <#>  

From above code from keyword view. we can use the <#> symbol for create parameterization.

Click the <#> Symbol in keyword view -> opened Value configuration option dialog box -> select parameter-> select "Data table" -> select name ( we can changes this name variable as per our wish) -> Select location in data table as Global sheet ( Global) or Current action sheet ( Action)  -> its create the variable name in datatable -> then give the value for variable in data table.


->Prior to data table parameterization focus on below 2 steps:

i) For Global Iteraion settings : The number of iteraion or repetitation is controlled from

File -> settings -> Run dualog -> we can see below three options

i)  Run one iteration only
ii) Run on all rows
iii)Run  from row X to row Y

Select any one of above option as per our needed.

ii) For Action Iteration Settings :

View -> Test Flow -> Right click on action node in test flow pane-> select Action call properties -> we can see below three options

i)  Run one iteration only
ii) Run on all rows
iii)Run  from row X to row Y


2) Test/Action Parameters ( Passing value from calling function(Script2) to called function (Script 1))

Step 1: Create called function/Action (Script 1)

-> We create one action for Gmail login, script looks like,

Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Email").Set "arun"
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Passwd").SetSecure "50d8459e3ef20b17b2d8d66d730b"
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebButton("Sign in").Click

-> saved script .

-> Right click on Action node and select Action properties. give the parameter name and data type in parameter tab. like

Name     type         Default Value       Description

Uname    String
Pswd     Password

-> Then you must use this input parameter in our script.

-> For use Uname Parameter Variable: from keyword view, select the cell which contains "arun" and click on  <#> symbol.-> Then value configuration dialog option open -> select parameter as Test/Action Parameters. and parameter name as Uname.

-> For use Pswd Parameter Variable : from keyword view, select the cell which contains "50d8459e3ef20b17b2d8d66d730b"(Password) and click on  <#> symbol.-> Then value configuration dialog option open -> select parameter as Test/Action Parameters. and parameter name as Pswd.

-> final script looks like

Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Email").Set Parameter("Uname")
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Passwd").SetSecure Parameter("Pswd")
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebButton("Sign in").Click

-> save the script name as script1.
  
Step 2: Create called function/Action (Script 2)

-> Create new script name as script2

-> select insert -> call to Existion Action -> From select Action dialog box -> select from test as script1 as login -> Click ok.Now its added the statment to call login action of script 1 from script2.

-> Script looks like

RunAction "Action1 [parameter1]", oneIteration

-> Right click on node login and select Action call properties -> display Action call properties dialog -> select parameter values tab -> Enter value for Uname and Pswd like

Name     type         Default Value       Description

Uname    String        DemoUser  
Pswd     Password      *******

-> final script looks like
RunAction "Action1 [parameter1]", oneIteration, "DemoUser", "50d843bc6f4f3633"

-> Click ok and run the script

-> Now script2 calls Action login from script1 and passess username and password as DemoUser and *******


3)Random Number Parameterization

Enable you to insert random number in your test.

-> For use Random Number Parameterization : from keyword view, select the cell which contains "Gmail" and click on  <#> symbol.-> Then value configuration dialog option open -> select parameter as Random Number Parameterization.

-> Select the following option for configuring Random Number Parameterization

i)  Numeric Range - Enter the number range which random number generated.
ii) Name    - Assigns the vaiable name to your parameter.
iii)Generate New random number:

   For Each Action Iteration - Generate new number at end of each action iteration.
   For Each Test Iteration - Generate new number at end of each test iteration.
    once per entire test run - Generate a new number the first time the parameter is used. This same number used for parameter throughout the test run.


4) Environmental Variable parameterization

Its enable to use variable values from Environmental variables.Three types of method available in below,

i) Built in - its vaiable predefined in system like OS informtion and Action Name.

ii) User Defined Internal - The variable we can defined and use in the test. To create user defined inernal variable -> select File -> Settings -> Environment ->  User Defined -> Click add symbol -> add User defined variables

iii) User Defined External - we can use environmental varibles present in XML file.

To create user defined External variable -> select File -> Settings -> Environment ->  User Defined -> add the XML File.

In Xml file we should use below elements,

-> Type <Environment> elements in first line.like below section

<Environment>
<Variable>
<Name>Gmail_ID</Name>
<Value>QTP_USer</Value>
</Variable>
</Environment>

-> For use Environmental vaialbe Parameterization : from keyword view, select the cell which contains "Gmail" and click on  <#> symbol.-> Then value configuration dialog option open -> select parameter as Environmental vaialbe Parameterization -> Select name and value for parameter.

No comments:

Post a Comment