Micro Focus QTP (UFT) Forums

Full Version: New Test Parameters
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi

Can we create the test parameters using vb sscript without adding them in Settings->Parameters tab in QTP? If yes, please let me know the process.
there is no direct method to do this, however you can use QTP AOM to achieve this. e.g
Code:
Test.Actions.Item(1).ActionParameterDefinitions.Add "InParam", "Param1", 0, 0, "Input Value"

for more detail, search for "ActionParameterDefinitions" in qtp help.
Hi,
Isn't above script for adding action parameters ,not test parameters?Please correct me if I am wrong.
Hi Saket ,

My requirement is to create test parametersSad. Not action parameters
Hi,
Plz use this method for test parameters.


Code:
Set qtApp = CreateObject("QuickTest.Application")
qtApp.Launch
qtApp.Visible = True

'Open a test
qtApp.Open "C:\TestInputParams"

' Retrieve the parameters collection defined for the test.
Set oParams = qtApp.Test.ParameterDefinitions.GetParameters()

oParams.Item("InputDataFile").Value = "C:\NewTestData.xls"

' Run the test with changed parameters.
qtApp.Test.Run , True, oParams
This still requires the parameters to exist by creating them manually before running the test. As far as I am aware though this is the only way of setting params via a launch script and they cannot be created externally.
It's actually quite easy for Environment parameters to be created (they are the ones found under "File\Settings\Environment\User-defined" and are visible/editable in ALM/QC).
Code:
'Instantiate the QTP OTA
    Set App = CreateObject("QuickTest.Application")
    App.Launch
    App.Visible = True

'Open a test as required
    App.Open "C:\Program Files\HP\QuickTest Professional\Tests\trial", True

'To add an environment variable to a test
    App.Test.Environment("MyNewParam") = 2

'To change an existing variable just re-write over the variable
    App.Test.Environment("MyNewParam") = "Two"

'Exit safely ;)
App.Test.Save
App.Test.Close
App.Quit
Set App = Nothing
Not sure how you would delete a variable though...
Also not sure why it bypasses the ParameterDefinitions methods or if they are different in a way that would benefit the user to use them separately.