Highlighted
Absent Member.
Absent Member.
647 views

UFT v12.01 Error value cannot be null parameter name:key

HI all,

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 

g25
Set qtp = CreateObject("QuickTest.Application")

'Launch QTP
qtp.Launch

'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"
test.Run qtpResultsLocation

test.Close

Msgbox("Closed test.. closing application")
qtp.quit

 

 

Copy above vbs and execute.

Is it with v12.01?

0 Likes
1 Reply
Highlighted
Honored Contributor.. Honored Contributor..
Honored Contributor..

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.

 

Good luck!

 

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.