QTP - Test Parameter
Test Parameters can be used to pass values to the test and retrieve values when the test completes. They are global parameters and can be accessed in any action or rather any scope. They are of two type - Input and output. Input Parameters are used to pass values to the test while Output Parameters are used to retrieve values from the Test.
1. Open a New Test.
2. Go to File->Settings->Parameters Tab
3. Click on '+' sign which is on the top right.
4. Enter the Name of the parameter as 'vartest' and its Default Value as 'hello'. Click Apply and then Ok. The Type of this parameter is string.
5. Above we have created a Test Parameter.
6. Now in the Keyword View right click on Action1 and select 'Action Properties'. 'Action Properties' window opens.
7. Go to 'Parameters' Tab. Click on '+' sign which is on the top right.
8. Enter the Name of the parameter as 'varaction' and its Type as string and no default value. Click Ok to come out of that window.
9. Again in the Keyword View right click on Action1 and select 'Action Call Properties'. 'Action Call Properties' window opens.
10. Go to 'Parameter Values' Tab. There you will see the 'varaction' action parameter we created earlier. Make a single click under 'Value' heading, it will show a button like this <#>. Just click on this button to open 'Value Configuration Options' window.
11. Click on 'Parameter' radio button and select 'Test/action Parameter' from that dropdown.
12. 'Test Parameters' radio button will be selected by default and under 'Test Parameters' radio button select 'vartest' from Parameter dropdown.[ remember this vartest is a test parameter we created at the beginning]
13. When you click on ok to come out of 'Value Configuration Options' window, in the 'Action Call Properties' window, under 'Value' it will show . Click Ok.
14. Go to Expert View and type: msgbox(parameter("varaction"))
15. Now run the test. While running it will show 'hello' in the msgbox.
Labels: QTP - Theory

0 Comments:
Post a Comment
<< Home