469,626 Members | 1,369 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,626 developers. It's quick & easy.

Get Command Line Argument

2
Hello,
Iím trying to use my vbs script to get a command line argument for a file which will need to be opened through QuickTestPro. Below are the commands Iím using:

Dim qt_file 'As String -> If I donít comment out the As String, I get an ďExpected end of statementĒ error Ė is this correct??
qt_file = Command -> This doesnít appear to be correct Ė when I echo out qt_file itís null
qtApp.Test.DataTable.Import qt_file ' Import data from an external file provided by command line -> This command should open the file in QTP that was provided at the command line. If I set qt_file to a shared drive file it works fine.

Can someone please help me w/ the correct syntax? The full program is below:

'************************************************* ************************************************** *********************
'Description:
'
'This example opens a test, configures run options and settings,
'runs the test, and then checks the results of the test run.
'
'Assumptions:
'There is no unsaved test currently open in QuickTest.
'For more information, see the example for the Test.SaveAs method.
'When QuickTest opens, it loads the add-ins required for the test.
'For more information, see the example for the Test.GetAssociatedAddins method.
'************************************************* ************************************************** *********************
'Option Explicit
Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim qtTest 'As QuickTest.Test ' Declare a Test object variable
Dim qtResultsOpt 'As QuickTest.RunResultsOptions ' Declare a Run Results Options object variable
Dim qt_file 'As String

Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
qtApp.Launch ' Start QuickTest
qtApp.Visible = True ' Make the QuickTest application visible
'qt_file = "L:\SCM\TM\test.xls"
qt_file = Command()
MsgBox "Command file: " & qt_file

' Set QuickTest run options
qtApp.Options.Run.CaptureForTestResults = "OnError"
qtApp.Options.Run.RunMode = "Fast"
qtApp.Options.Run.ViewResults = False

qtApp.Open "C:\Program Files\Mercury Interactive\QuickTest Professional\Tests\tm_accts", True ' Open the test in read-only mode

' set run settings for the test
Set qtTest = qtApp.Test
qtTest.Settings.Run.IterationMode = "rngAll"
qtTest.Settings.Run.OnError = "NextStep" ' Instruct QuickTest to perform next step when error occurs

' Import data to the design-time Data Table and then add new data
qtApp.Test.DataTable.Import qt_file ' Import data from an external file provided by command line
qtApp.Test.DataTable.ImportSheet qt_file, "Query", "Action1" ' Import a single sheet
'qtApp.Test.DataTable.Import "C:\test.xls" ' Import data from an external file
'qtApp.Test.DataTable.ImportSheet "C:\test.xls", "Query", "Action1" ' Import a single sheet

Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object
qtResultsOpt.ResultsLocation = "C:\temp\Results" ' Set the results location

qtTest.Run qtResultsOpt ' Run the test

' Save the Run-time Data Table
qtApp.Test.LastRunResults.DataTable.Export "C:\Runtime.xls" ' Save the run-time Data Table to a file

' MsgBox qtTest.LastRunResults.Status ' Check the results of the test run
If qtTest.LastRunResults.Status="Failed" then
WScript.stdout.WriteLine "Test failed"
Else
WScript.stdout.WriteLine "Test successful"
End if

qtTest.Close ' Close the test
qtApp.quit ' Close the app

Set qtResultsOpt = Nothing ' Release the Run Results Options object
Set qtTest = Nothing ' Release the Test object
Set qtApp = Nothing ' Release the Application object
Oct 17 '06 #1
3 9878
willakawill
1,646 1GB
Hello,
Iím trying to use my vbs script to get a command line argument for a file which will need to be opened through QuickTestPro. Below are the commands Iím using:

Dim qt_file 'As String -> If I donít comment out the As String, I get an ďExpected end of statementĒ error Ė is this correct??
qt_file = Command -> This doesnít appear to be correct Ė when I echo out qt_file itís null
qtApp.Test.DataTable.Import qt_file ' Import data from an external file provided by command line -> This command should open the file in QTP that was provided at the command line. If I set qt_file to a shared drive file it works fine.

Can someone please help me w/ the correct syntax? The full program is below:

'************************************************* ************************************************** *********************
'Description:
'
'This example opens a test, configures run options and settings,
'runs the test, and then checks the results of the test run.
'
'Assumptions:
'There is no unsaved test currently open in QuickTest.
'For more information, see the example for the Test.SaveAs method.
'When QuickTest opens, it loads the add-ins required for the test.
'For more information, see the example for the Test.GetAssociatedAddins method.
'************************************************* ************************************************** *********************
'Option Explicit
Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim qtTest 'As QuickTest.Test ' Declare a Test object variable
Dim qtResultsOpt 'As QuickTest.RunResultsOptions ' Declare a Run Results Options object variable
Dim qt_file 'As String

Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
qtApp.Launch ' Start QuickTest
qtApp.Visible = True ' Make the QuickTest application visible
'qt_file = "L:\SCM\TM\test.xls"
qt_file = Command()
MsgBox "Command file: " & qt_file

' Set QuickTest run options
qtApp.Options.Run.CaptureForTestResults = "OnError"
qtApp.Options.Run.RunMode = "Fast"
qtApp.Options.Run.ViewResults = False

qtApp.Open "C:\Program Files\Mercury Interactive\QuickTest Professional\Tests\tm_accts", True ' Open the test in read-only mode

' set run settings for the test
Set qtTest = qtApp.Test
qtTest.Settings.Run.IterationMode = "rngAll"
qtTest.Settings.Run.OnError = "NextStep" ' Instruct QuickTest to perform next step when error occurs

' Import data to the design-time Data Table and then add new data
qtApp.Test.DataTable.Import qt_file ' Import data from an external file provided by command line
qtApp.Test.DataTable.ImportSheet qt_file, "Query", "Action1" ' Import a single sheet
'qtApp.Test.DataTable.Import "C:\test.xls" ' Import data from an external file
'qtApp.Test.DataTable.ImportSheet "C:\test.xls", "Query", "Action1" ' Import a single sheet

Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object
qtResultsOpt.ResultsLocation = "C:\temp\Results" ' Set the results location

qtTest.Run qtResultsOpt ' Run the test

' Save the Run-time Data Table
qtApp.Test.LastRunResults.DataTable.Export "C:\Runtime.xls" ' Save the run-time Data Table to a file

' MsgBox qtTest.LastRunResults.Status ' Check the results of the test run
If qtTest.LastRunResults.Status="Failed" then
WScript.stdout.WriteLine "Test failed"
Else
WScript.stdout.WriteLine "Test successful"
End if

qtTest.Close ' Close the test
qtApp.quit ' Close the app

Set qtResultsOpt = Nothing ' Release the Run Results Options object
Set qtTest = Nothing ' Release the Test object
Set qtApp = Nothing ' Release the Application object
Is this code that you wrote yourself?
Oct 17 '06 #2
jlw16
2
No, this was code provided by Quick Test Pro that I modified. I think I got it working though using:

qt_file = WScript.Arguments.Item(0)
Wscript.Echo "File Path: " & qt_file

instead of the qt_file = Command line.

Thanks!
Oct 17 '06 #3
Hi,
Where can I find help of all methods and properties of QuickTest application object. I want to manage everything throgh programming in QuickTest.
May 19 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Bernd Danberg | last post: by
3 posts views Thread by Shailesh Humbad | last post: by
34 posts views Thread by Roman Mashak | last post: by
6 posts views Thread by evantri | last post: by
6 posts views Thread by =?Utf-8?B?Rm9ycmVzdCBIZWxsZXI=?= | last post: by
2 posts views Thread by =?Utf-8?B?UmFtb24gR2VuZQ==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.