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
3 10298
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?
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!
Hi,
Where can I find help of all methods and properties of QuickTest application object. I want to manage everything throgh programming in QuickTest.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Joe |
last post by:
I'm using Python 2.4 on Windows XP SP2.
I'm trying to receive a command line argument that is a newline (\n)
Here is the command line to use
sample.py "\n"
Here is a sample.py script
|
by: Bernd Danberg |
last post by:
Hi,
I have a real strange problem with the command line arguments given to the
main-function and together with using std::string:
#include <string>
int _tmain(int argc, _TCHAR* argv)
{...
|
by: SunRise |
last post by:
Hi
I am creating a C Program , to extract
only-Printable-characters from a file ( any type of file) and display
them.
OS: Windows-XP
Ple help me to fix the Errors & Warnings and explain...
|
by: Shailesh Humbad |
last post by:
I want to set a command-line argument for a Windows service that I
programmed in VB.Net. This ought to be available from the service
installer classes, but I can not find any such property. What...
|
by: amirmira |
last post by:
I would like to set command line arguments to a service at install time. I
need to do this because I need to get information from different registry
locations depending on my command line argument....
|
by: Roman Mashak |
last post by:
Hello, All!
I'm implementing simple CLI (flat model, no tree-style menu etc.). Command
line looks like this: <command> <param1> <param2> ... <paramN> (where
N=1..4)
And idea is pretty simple:
...
|
by: evantri |
last post by:
I am developing a program that prompt the input from the command line argument. For example, this is the lists of command line arguments that I want to include:
-fish
-cat
-dog
-animal
All...
|
by: =?Utf-8?B?Rm9ycmVzdCBIZWxsZXI=?= |
last post by:
The only code that is helpful is this:
fp = New IO.StreamReader(filename, New
System.Text.UnicodeEncoding(True, False), False)
If I pass a command line argument to my program that is not from...
|
by: Ojas |
last post by:
Hi!,
I just out of curiosity want to know how top detect the client side
application under which the script is getting run. I mean to ask the
how to know whether the script is running under...
|
by: =?Utf-8?B?UmFtb24gR2VuZQ==?= |
last post by:
Hello:
I am building a console application and I am having an issue with the
command line arguments. A couple of my arguments are paths and they are
usually enclosed in double quotes. If one of...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |