Thursday, December 23, 2010

Automation Object Model

'Open QTP and Connect to Quality Center  
'************************************************************************************************* 
Dim qtApp ' Declare the Application object variable  
Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object  
qtApp.Launch ' Start QuickTest  
qtApp.Visible = True ' Make the QuickTest application visible  

' Make changes in a test on Quality Center with version control  
qtApp.TDConnection.Connect "QC URL", "DOMAIN Name", "Project Name", "User Name", "Password", False ' Connect to Quality Center     
 
If qtApp.TDConnection.IsConnected Then ' If connection is successful  
 MsgBox "Succesfully connected to Quality Center" 
Else 
    MsgBox "Cannot connect to Quality Center" 
End If 

qtApp.Quit ' Exit QuickTest  
Set qtApp = Nothing ' Release the Application object  
'************************************************************************************************* 
'*************************************************************************************************
'Start  QTP and open New test  
'*************************************************************************************************
'************************************************************************************************* 
Dim qtApp ' Declare the application object variable  
Set qtApp = CreateObject("QuickTest.Application") ' Create the application object  
 
qtApp.Launch ' Start QuickTest  
qtApp.Visible = True ' Make the QuickTest application visible  
 
qtApp.New ' Open a new test  
 
Set qtApp = Nothing ' Release the Application object  
'************************************************************************************************* 
'*************************************************************************************************  
'Start  QTP, open an existing test and Run the Test  
'*************************************************************************************************  
'*************************************************************************************************  
Dim qtApp  
Dim qtTest  
 
Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object  
qtApp.Launch ' Start QuickTest  
qtApp.Visible = True ' Make the QuickTest application visible  
 
' Set QuickTest 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.OnError = "NextStep" ' Instruct QuickTest to perform next step when error occurs  
 
qtTest.Run ' Run the test  
 
MsgBox qtTest.LastRunResults.Status ' Check the results of the test run  
qtTest.Close ' Close the test  
 
Set qtTest = Nothing ' Release the Test object  
Set qtApp = Nothing ' Release the Application object  
'*************************************************************************************************

No comments:

Post a Comment