UFT v12.01 Error value cannot be null parameter name:key
I exeucted sample VBS script where i need to pass parameter value from VBS to Test ,where i am getting error .
please find below sample code
Set qtp = CreateObject("QuickTest.Application")
'Set QTP visible
qtp.Visible = True
'Run Mode - Fast
qtp.Options.Run.RunMode = "Fast"
'View Results - True
qtp.Options.Run.ViewResults = True
'Open the test
qtp.open "C:\Auto\Driver Script\TC_01", True
Set test = qtp.Test
Set params = test.ParameterDefinitions.GetParameters()
parameter1 = "par1"
parameter2 = "par2"
params.Item(par1).Value = "This is my first parameter"
params.Item(par2).Value = "This is my second parameter"
Set qtpResultsLocation = CreateObject("QuickTest.RunResultsOptions")
qtpResultsLocation.ResultsLocation = "C:\Auto"
Msgbox("Closed test.. closing application")
Copy above vbs and execute.
Is it with v12.01?
Hi, and welcome to the forum!
There are some key elements that must be enlightened here. First I recommend you to read up on the differences between test parameters and action parameters. This brilliant blog post is a perfect start.
Then over to your actual problem.
parameter1 = "par1" parameter2 = "par2" params.Item(parameter1).Value = "This is my first parameter" params.Item(parameter2).Value = "This is my second parameter"
You have mistaken the variable names and it should be set as adjusted above. Appropriate values can be either integers, starting on 1, or the names of the given parameters you are referring to. As in your case you must have two test parameters in your test in UFT named par1 and par2.
Additionally, you have a second error since you are not passing the parameters to your actual test:
test.Run qtpResultsLocation, True, params
Here you must add the WaitOnReturn boolean and the actual parameters to be used during execution. If you omit this, the default value of your parameters would be empty.
Conclusively, if you want to test that you have succeeded, use the TestArgs([Parameter name]) to get the Default value of your parameters.