We touched upon the use of parameters in QTP through Datatable in our previous guide. This guide will delve into the remaining three strategies of parameterization in QTP:
2) Generating random number parameters
Recommended IPTV Service Providers
- IPTVGREAT – Rating 4.8/5 ( 600+ Reviews )
- IPTVRESALE – Rating 5/5 ( 200+ Reviews )
- IPTVGANG – Rating 4.7/5 ( 1200+ Reviews )
- IPTVUNLOCK – Rating 5/5 ( 65 Reviews )
- IPTVFOLLOW -Rating 5/5 ( 48 Reviews )
- IPTVTOPS – Rating 5/5 ( 43 Reviews )
3) Adjustments through environment variable parameters
4) Test/Action parameter manipulation
To acquire more knowledge about QTP, check our comprehensive QTP Training Tutorial Series here.
This Guide Covers:
#2 – Utilizing Random Number for Parameterization in QTP
To designate a random number within a specified range to a field in QTP, select the “Random number” option in the Value configuration properties panel. One can select the range and the frequency of the value’s generation during a specific iteration or test run. This functionality is helpful for scenarios in which it is necessary to validate the numeric breadth of data in an automated test.
Sample code:
Browser("Google").Page("Google").WebEdit("q").Set RandomNumber("p_Text")
#3 – Parameterization in QTP with Environment Variables
Within QTP, environment variables are set values that remain consistent throughout a test run, unless deliberately modified by the software. Exist three variants of environment variables:
- Custom internal variables
- Custom external variables
- Pre-set variables
QTP creates pre-set variables that carry information about the test path, operating system, etc. These read-only variables can be employed as they are. Examples comprise TestIteration, OS, OSVersion, etc.
Custom internal variables can be established inside the test and their values can be modified as needed. Custom external variables are externally created and associated with the test.
Sample code for implementing an environment variable:
Browser("Google").Page("Google").WebEdit("q").Set Environment("PV")
3 Different Environment Variables
Environment variables can be set and utilized via the Parameters tab of the Action Properties dialog box for actions, or in the Parameters tab of Test Settings for tests.
#4 – Manipulating Action and Test Parameters in QTP Parameterization
Within QTP, a test essentially constitutes a call to an action. Action and test parameters denote values that are transmitted to actions or tests from other sections of the test. They could be input values, output values, or potentially values acquired from top-level actions.
Output parameters represent the return values of an action that can subsequently be used within the test. Parameters can be deployed as arguments or by utilizing the “Parameter” keyword.
Sample code:
Browser("Gmail: Email from Google").Page("GoogleAccounts").WebEdit("FirstName").Set Parameter("OPFirstName")
Parameters can be formed, modified, and eradicated in the Parameters tab of the Action Properties dialog box for actions, or in the Parameters tab of Test Settings for tests.
We have now concluded our guide on parameter utilization in QTP. We have explored various strategies including parameterization through Datatable, random number generation, adjustment via environment variables, and modification through action/test parameters. These strategies prove handy for automating tests where data needs fluctuation or needs to be sourced from exterior inputs. Visit our QTP Training Tutorial Series here for more insightful QTP guides. Feel free to drop your queries or comments below.
In the pipeline: actions, functions, and methods for error management.