Open Method
Description
Opens an existing test.
Syntax
Visual Basic |
---|
Public Sub Open( _ ByVal TestPath As String, _ Optional ByVal OpenInReadOnlyMode As Boolean = False, _ Optional ByVal SaveCurrent/SaveAll As Boolean = False _ ) |
Parameters
TestPath | The full path of the test to open. |
OpenInReadOnlyMode | Indicates whether to open the test in read-only mode.
|
SaveCurrent (Versions 2021 R1 and earlier) | Indicates whether to save changes for the selected open test, component, or application area in the currently open solution before opening the specified test.
|
SaveAll (Versions 2022 and later) | Indicates whether to save changes for all open tests, components, and application areas in the currently open solution before opening the specified test.
|
Remarks
This method is valid only for tests. To open a business component, use the OpenBusinessComponent method. To open an application area, use the OpenAppArea method.
You can enter an Application.Open statement without an Application.Launch statement. If OpenText Functional Testing is not already running when the Open method is called, OpenText Functional Testing is automatically started.
Example
'************************************************************************************************************************
'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.
'For more information, see the example for the Test.SaveAs method.
'When the testing application opens, it loads the add-ins required for the test.
'For more information, see the example for the Test.GetAssociatedAddins method.
'************************************************************************************************************************
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 qtAutoExportResultsOpts 'As QuickTest.AutoExportReportConfigOptions ' Declare the Automatically Export Report Configuration Options object variable
Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
qtApp.Launch ' Start the testing application
qtApp.Visible = True ' Make the application visible
' Set run options
qtApp.Options.Run.ImageCaptureForTestResults = "OnError"
qtApp.Options.Run.RunMode = "Fast"
qtApp.Options.Run.ViewResults = False
qtApp.Open "C:\Tests\Test1", True ' Open the test in read-only mode
' set run settings for the test
Set qtTest = qtApp.Test
qtTest.Settings.Run.IterationMode = "rngIterations" ' Run only iterations 2 to 4
qtTest.Settings.Run.StartIteration = 2
qtTest.Settings.Run.EndIteration = 4
qtTest.Settings.Run.OnError = "NextStep" ' Perform the next step when error occurs
Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object
qtResultsOpt.ResultsLocation = "C:\Tests\Test1\Res1" ' Set the results location
' Set options for automatic export of run results at the end of every run session
Set qtAutoExportResultsOpts = qtApp.Options.Run.AutoExportReportConfig
qtAutoExportResultsOpts.AutoExportResults = True ' Automatically export the run results at the end of each run session
qtAutoExportResultsOpts.StepDetailsReport = True ' Automatically export the step details part of the run results at the end of each run session
qtAutoExportResultsOpts.DataTableReport = True ' Automatically export the data table part of the run results at the end of each run session
qtAutoExportResultsOpts.LogTrackingReport = True ' Automatically export the log tracking part of the run results at the end of each run session
qtAutoExportResultsOpts.ScreenRecorderReport = True ' Automatically export the screen recorder part of the run results at the end of each run session
qtAutoExportResultsOpts.SystemMonitorReport = False ' Do not automatically export the system monitor part of the run results at the end of each run session
qtAutoExportResultsOpts.ExportLocation = "C:\Documents and Settings\All Users\Desktop" 'Automatically export the run results to the Desktop at the end of each run session
qtAutoExportResultsOpts.UserDefinedXSL = "C:\Documents and Settings\All Users\Desktop\MyCustXSL.xsl" ' Specify the customized XSL file when exporting the run results data
qtAutoExportResultsOpts.StepDetailsReportFormat = "UserDefined" ' Use a customized XSL file when exporting the run results data
qtAutoExportResultsOpts.ExportForFailedRunsOnly = True ' Automatically export run results only for failed runs
qtTest.Run qtResultsOpt ' Run the test
MsgBox qtTest.LastRunResults.Status ' Check the results of the test run
qtTest.Close ' Close the test
Set qtResultsOpt = Nothing ' Release the Run Results Options object
Set qtTest = Nothing ' Release the Test object
Set qtApp = Nothing ' Release the Application object
Set qtAutoExportSettings = Nothing ' Release the Automatically Export Report Configuration Options object
'************************************************************************************************************************
'Description:
'
'This example specifies a folder in which tests from an older version are
'stored and then loops through each test in the folder (and its subfolders) to open
'each one and save it in the current version format.
'
'************************************************************************************************************************
Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim filesys
Dim maindir
Dim testCol
Dim checkfolder
' Create the QuickTest.Application object that represents the testing application
Set qtApp = CreateObject("QuickTest.Application")
qtApp.Launch
qtApp.Visible = True
' Get the collection of test scripts
Set filesys = CreateObject("Scripting.FileSystemObject")
' TO DO: Specify the test script directory....
Set maindir = filesys.GetFolder("C:\temp")
Set testCol = maindir.SubFolders
' Loop through each test in the collection
For Each fl In testCol
' Verify the folder is a test
checkfolder = fl.Path & "\Action0"
If (filesys.FolderExists(checkfolder)) Then ' The folder is a test folder
' Convert test
qtApp.Open fl.Path, False, False
' wscript.sleep 1000
' Save converted test
qtApp.Test.Save
End If
Next
qtApp.Quit
' Release the File System Objects
Set testCol = Nothing
Set maindir = Nothing
Set filesys = Nothing
' Release the QuickTest.Application object
Set qtApp = Nothing
See Also