Saturday, June 21, 2008

Parameterization in QTP

There are four types of parameters:

  • Data Table: Data table is just an excel sheet where you can put the data and use this data as a parameter.
    There are two types of data table in QTP

    • Global Sheet: The Data in the global sheet will be available to all the Action of the test in which it is defined.
      DataTable("Column Name", dtGlobalShet) = "Value" 'To Add the Value in the Current Row
      DataTable("Column Name", dtGlobalShet) ' To Reterive the value of the current row of specified column
      The Number of rows in the Global Data sheet will define the number of the Test Iteration (It's a Test Iteration and not the Action Iteration. All the action in the test will run)
    • Local Sheet: The Data in the local sheet is available to only that action in which it is defined. Each and every action has it correspondent sheet with name same as actions' name.
      You need to change the Action call Properties to run the multiple iteration of the action depends on the data sheet.
  • Parameter : It's just like the variable we define in other languages. Here it is provided by QTP. There are Three types of parameter

    • Action Parameter : You can Define the parameter per action. This will not be available to any other action in the test. Syntax to access the parameter. Parameter("Name") = Value ' to assign the new value to parameter Msgbox Parameter("Name") ' to use the parameter value.

    • Test Parameter: Same as action parameter only the difference is that it will be available to all the actions in the test in which it is define. Syntax to access the Test Parameter. It is useful when you want to pass some parameter from one action to another action in the same test.
      TestArgs("Name") = Value ' to assign the new value to parameter.
      MsgBox TestArgs("Name") ' to use the Parameter value in test.

    • Component Parameter: Same as test parameter. But used in the component.

  • Environment Variable : There are actually two kind of Environment variables.

    • Build-in: This is the QTP in Build parameter. It containing many of the useful information like UserName, TestDir, etc...

    • User-Defined: You can define your own Environment Variable here. There are two kind of user define environment variable

      • Internal: You can define our own variable and it's value here.

      • External : You can use the variables from other XML file. But for that you need to have special XML file as below:
        of the Variable </Name>
        <Value> Value you want to assign </Value>>
        Note: external parameter will be read only parameter


Anonymous said...

nice work dude . It was pretty much detailed .

Post a Comment