Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extract data from test and use it in another test
#1
Solved: 11 Years, 4 Months, 3 Weeks ago
Hi All,

Can I use the "output value" to output text form one test and use it in another test?

Thanks
Jody
Reply
#2
Solved: 11 Years, 4 Months, 3 Weeks ago
No, you cant do this directly, you will have to put this into output parameter of one test and take it into the input parameter of another test.
or you can set the value in data table and use it.

Reply
#3
Solved: 11 Years, 4 Months, 3 Weeks ago
However, I am using a function to generate a string in test1 and want to use that string in test 2.
It is assumed that I don't need to remember the generated string and can ne used in test 2.

Input parameter can also achieve it?

Thanks
Jody
Reply
#4
Solved: 11 Years, 4 Months, 3 Weeks ago
Yes, the returned string from your function in test1 should go in the Output parameter for test1
and use the O/P parameter of test1 as input parameter for test2.

Reply
#5
Solved: 11 Years, 4 Months, 3 Weeks ago
Can it really transfer to another Test file?
it seems that output values from test1 and only be used later within only test1.
it is because it stored the output value in a globalsheet.

However, when I open Test2,,the value in global files become blank. Then, how can I make it as a input parameter of test 2?

Thanks
Jody
Reply
#6
Solved: 11 Years, 4 Months, 3 Weeks ago
oh sorry, my mistake. I assumed you are calling tests in an script.
this is not possible if these are two seperate scripts unless you call the scripts through a vbscript.

Reply
#7
Solved: 11 Years, 4 Months, 3 Weeks ago
Write the output from test1 to a excel or filesystemobject. For Test2 read value from the excel data. Does this help ?
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply
#8
Solved: 11 Years, 4 Months, 3 Weeks ago
if you are using QTP AOM then you can easily do this
see if the code below gives you an idea

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

qtResultsOpt.ResultsLocation = "D:\results"

qtApp.Open "C:\QTP\Script\Script1"

' parameters collection defined
Set pDefColl = qtApp.Test.ParameterDefinitions

Set oParams = pDefColl.GetParameters()

'added parameters Run the script
qtApp.Test.Run qtResultsOpt, True, oParams

'Extract the output Parameter
Set oParam = oParams.Item("OutputVal")

qtApp.Test.Close

qtApp.Open "C:\QTP\Script\Script2"


Set pDefColl = qtApp.Test.ParameterDefinitions

Set iParams = pDefColl.GetParameters()

Set iParam = iParams.Item("InputVal")

'add input parameter taken from earlier test
qtApp.Test.Run qtResultsOpt, True, iParam

missed to assign ouput parameter to the input parameter for second run in the code
try this -
Code:
Set qtApp = CreateObject("QuickTest.Application")
Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions")
qtApp.Launch
qtApp.Visible = True

qtResultsOpt.ResultsLocation = "D:\results"

qtApp.Open "C:\QTP\Script\Script1"

' parameters collection defined
Set pDefColl = qtApp.Test.ParameterDefinitions

Set oParams = pDefColl.GetParameters()

'added parameters Run the script
qtApp.Test.Run qtResultsOpt, True, oParams

'Extract the output Parameter
Set oParam = oParams.Item("OutputVal")

qtApp.Test.Close

qtApp.Open "C:\QTP\Script\Script2"


Set pDefColl = qtApp.Test.ParameterDefinitions

Set iParams = pDefColl.GetParameters()

Set iParam = iParams.Item("InputVal")

iParam.Value = oParam.Value

'add input parameter taken from earlier test
qtApp.Test.Run qtResultsOpt, True, iParam

Reply
#9
Solved: 11 Years, 4 Months, 3 Weeks ago
Hey Saket,
Can you give me an example (simple one) for the output parameter of one test and take it into the input parameter of another test.?? Sad
Reply
#10
Solved: 11 Years, 4 Months, 3 Weeks ago
Quick-and-dirty alternate method using Windows environment variables:

Code:
Sub SetSysEnv(strSysEnvVar,strValue)
    Set WshShell = CreateObject("WScript.Shell")
    Set WshSysEnv = WshShell.Environment("SYSTEM")
    WshSysEnv(strSysEnvVar) = strValue
    Set WshShell = Nothing
    Set WshSysEnv = Nothing
End Sub

Function GetSysEnv(strSysEnvVar)
    Set WshShell = CreateObject("WScript.Shell")
    Set WshSysEnv = WshShell.Environment("SYSTEM")
    GetSysEnv = WshSysEnv(strSysEnvVar)
    Set WshShell = Nothing
    Set WshSysEnv = Nothing
End Function

Archens
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Send automatic email notification when test run started helmzshelmz 0 1,114 04-03-2020, 07:54 AM
Last Post: helmzshelmz
  Multiple rows of test data Bhuvana 0 1,358 01-03-2020, 09:30 PM
Last Post: Bhuvana
  Can we test Salesforce Standard form using QTP? yona34 0 1,094 05-22-2018, 10:57 AM
Last Post: yona34
  issue with IE when running test eiko 2 1,604 02-01-2018, 04:46 PM
Last Post: eiko
  Test runned from QualityCenter generated an error "Attempted to divide by zero." robertosalemi 1 2,592 10-14-2016, 08:38 PM
Last Post: robertosalemi

Forum Jump:


Users browsing this thread: 1 Guest(s)