Documente Academic
Documente Profesional
Documente Cultură
Posted In | Automation Testing, QTP Tutorials In part 1 of this QTP Parameterization tutorial we explained Datatable Parameterization with example. In this QTP tutorial lets focus on remaining three parameterization techniques: 2) Random number parameters 3) Environment variable parameters 4) Test/Action parameters
following options come up: As you can see, the options are pretty self explanatory. The range can be set and how many times during a particular iteration run or a test run should this value be generated can be programmed here. Let us just keep the default settings and click OK and see the line of code that gets inserted. 1Browser("Google").Page("Google").WebEdit("q").Set RandomNumber("p_Text")
In real time, this is a very useful feature that can help the tester automate the scenarios in which the numeric range of data needs to be verified.
From the above screen, you can see that the type is read only and we are only able to create a user defined- internal environment variable.
Even though we have not created any environment variables in this test so far there are many of them available in the drop down to be used. Select any one of them:
It shows that the variable is a built-in and read only. So this shows how we can use a built in variable.
But if we need a new one, enter a new name, say PV assign 0 and save it:
Let us first accept the default values and enter a 0 in the value field and click OK. The following is the line of code that gets inserted: 1Browser("Google").Page("Google").WebEdit("q").Set Environment("PV") Since we inserted an E.V. it is obvious that the value of PV is going to be 0 throughout the test. The next time you are trying to parameterize anything else with an environment variable within the test this one will be available in the list. User defined external: In case when we need to have an entire list of environment variables available for a test, the user has an option to create it externally and associate it to the test and make those variable available to this test. Typically, this file is an .xml with the structure as follow and is available on your desktop: 1 2 <Environment> <Variable> 3 <Name>First Name</Name> 4 <Value>Swati</Value> 5 </Variable> 6 <Variable> 7 <Name>Last Name</Name> <Value>Seela</Value> 8 </Variable> 9 </Environment> 10 Once this is set, we can add this file to the test by going to File->Settings->Environment and selecting User defined from the drop down:
In the screen, you can see the option to add the file, so ahead and add it. Alternately, if I need the variables in this test for another one, I can export them into a file by clicking on Export option. So now that we know how to set and use environment variables, there is yet another use for these: In case, we set the values for URL_env and Browser_env variables, then the record and run settings set overrun and no matter what you set there, it is going to consider the values that these variables contain.
These can be used as a parameter by using the Parameter keyword. If this is the statement that you need to parameterize so that the value you set is not a constant swati but a value that is the input value of an action that is already defined, say OPFirstName: 1Google").Page("GoogleAccounts").WebEdit("FirstName").Set "swati This is how it is done:
Browser("Gmail: Email from Browser("Gmail: Email from
1Google").Page("GoogleAccounts").WebEdit("FirstName").Set
Parameter(OPFirstName)
Also, if there is a output parameter that is already defined then you could also write something like: 1Google").Page("GoogleAccounts").WebEdit("FirstName") Now let us see, how the i/p or o/p parameters can be set in the first place. Lets start with an action. You can define, modify, and delete input and output parameters in the Parameters tab of the Action Properties dialog box (Edit > Action > Action Properties or right-click an action and select Action Properties).
Parameter("TotalValue") = Browser("Gmail: Email from
So, to call an action with the input parameters this is the statement that needs to be used: 1RunAction ActionName, IterationQuantity, Parameters This concludes our parameterization. Out of all that we have discussed in these 2 articles, the one that we use the most is the data table option. So please take some time to write a test and run it with all the iteration options to get a grip on this topic. Also dont forget to check all QTP tutorials on this page as well. As always, please let us know you comments and feel free to post your question. Coming topics are actions, functions and some error handling methods.