Micro Focus QTP (UFT) Forums
New Test Parameters - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: New Test Parameters (/Thread-New-Test-Parameters)



New Test Parameters - VenkataBonu - 08-09-2012

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.


RE: New Test Parameters - Saket - 08-09-2012

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.


RE: New Test Parameters - pradeep singh - 08-09-2012

Hi,
Isn't above script for adding action parameters ,not test parameters?Please correct me if I am wrong.


RE: New Test Parameters - VenkataBonu - 08-09-2012

Hi Saket ,

My requirement is to create test parametersSad. Not action parameters


RE: New Test Parameters - vIns - 08-09-2012

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



RE: New Test Parameters - SteveS - 08-09-2012

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.


RE: New Test Parameters - cflow - 12-10-2013

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.