Normal 0 false false false EN-US X-NONE X-NONE ...
Friday, 16 September 2011
QTP - AOM - Working with Actions
'Automation Object Model'*********************************************************** '**********************************************************' GAReddy @ OneTestingCenter @ QTP - AOM (Automation Object Model)' What ==> This is a QTP - AOM Script to Open QTP and to working actions' How ==> Need QuickTest.Application Automation Object to do so' Why ==> To Open a Driver Script (which could call other tests)' ...
QTP - AOM - Working with Environment Variables
Normal 0 false false false EN-US X-NONE X-NONE ...
QTP - AOM - Add Shared Object Repository to QTP
Normal 0 false false false EN-US X-NONE X-NONE ...
QTP - AOM - Add Functional Libraries - Run Tests - Save Results
'Automation Object Model'************************************************************************ '************************************************************************ ' GAReddy @ OneTestingCenter @ QTP - AOM (Automation Object Model)' What ==> This is a QTP - AOM Script to Open QTP , To Open Driver Script, To Add the functional LIBs to QTP and to Run the Test ' and store the results on to specified results directory (using the Run options)' How ==> Need QuickTest.Application Automation Object...
QTP - AOM - Open Driver Sctipt - Run Tests - Save Results
Normal 0 false false false EN-US X-NONE X-NONE ...
Friday, 16 September 2011
QTP - AOM - Running Batch Tests
'Automation Object Model
'********************************************************************
'********************************************************************
' GAReddy @ OneTestingCenter @ QTP - AOM (Automation Object Model)
' What ==> This is a QTP - AOM Script to Open QTP and to working with QTP Batch Tests
' How ==> Need QuickTest.Application Automation Object to do so
' Why ==> To number of tests (one by one )
' Author : GAReddy @ OneTestingCenter @ QTP
'******************************************************************
'******************************************************************
Set oQTP = CreateObject("QuickTest.Application")
oQTP.Launch
oQTP.Visible = True
oQTP.WindowState = "Maximized" ' Maximize the QuickTest window
oQTP.ActivateView "ExpertView" ' Display the Expert View
'oQTP.open "D:\OneTestingCenter\QTP\GAReddy@DemoTests\QTP_PageInfo", False
'Opens the test in editable mode
Dim QTP_Tests(4)
QTP_Tests(1)="D:\OneTestingCenter\QTP\GAReddy@DemoTests\QTP_PageInfo"
QTP_Tests(2)="D:\OneTestingCenter\QTP\GAReddy@DemoTests\QTP_WebEditInfo"
QTP_Tests(3)="D:\OneTestingCenter\QTP\GAReddy@DemoTests\QTP_RadioGroupInfo"
QTP_Tests(4)="D:\OneTestingCenter\QTP\GAReddy@DemoTests\QTP_ImagesInfo"
Set QTPResultsOptions=CreateObject("QuickTest.RunResultsOptions")
For i=1 To UBound(QTP_Tests)
oQTP.Open QTP_Tests(i), True
QTPResultsOptions.ResultsLocation=QTP_Tests(i)& "\Res1"
oQTP.Test.Run QTPResultsOptions, True
oQTP.Test.Close
Next
oQTP.Quit
Set QTPResultsOptions=Nothing
'Set QTP_Tests=Nothing
Set oQTP=Nothing
'***************************************************************
'***************************************************************
QTP - AOM - Working with Actions
'Automation Object Model
'***********************************************************
'**********************************************************
' GAReddy @ OneTestingCenter @ QTP - AOM (Automation Object Model)
' What ==> This is a QTP - AOM Script to Open QTP and to working actions
' How ==> Need QuickTest.Application Automation Object to do so
' Why ==> To Open a Driver Script (which could call other tests)
' To get all the action names in test
' Author : GAReddy @ OneTestingCenter @ QTP
'**************************************************************
'**************************************************************
Dim oQTP
' Open QuickTest
Set oQTP = CreateObject("QuickTest.Application") ' Create the Application object
oQTP.Launch ' Launch QuickTest
oQTP.Visible = True ' Set QuickTest to be visible
oQTP.Open "D:\GAReddy\OneTestingCenter\QTP\AprilBatch\KeywordDrivenFramework\TestScripts\DriverScript", False, False ' Open a test
nActionsCount=oQTP.Test.Actions.Count
For i=1 to nActionsCount
' Get the first action in the test by index (start from 1)
MsgBox oQTP.Test.Actions(i).Name
Next
'Close QuickTest
oQTP.Quit ' Quit QuickTest
Set oQTP = Nothing ' Release the Application object
'*****************************************************************
'****************************************************************
QTP - AOM - Working with Environment Variables
'Automation Object Model
'******************************************************************
'******************************************************************
' GAReddy @ OneTestingCenter @ QTP - AOM (Automation Object Model)
' What ==> This is a QTP - AOM Script to Open QTP and to work with Environment Variables
' How ==> Need QuickTest.Application Automation Object to do so
' Why ==> To Open a Driver Script (which could call other tests)
' To work with Environment Variables in QTP
' Author : GAReddy @ OneTestingCenter @QTP
'******************************************************************
'*****************************************************************
Dim oQTP
Set oQTP = CreateObject("QuickTest.Application") ' Create the Application object
oQTP.Launch ' Start QuickTest
oQTP.Visible = True ' Make the QuickTest application visible
' Open the test
oQTP.Open "D:\GAReddy\OneTestingCenter\QTP\AprilBatch\KeywordDrivenFramework\TestScripts\DriverScript", False
' Open a test named Driver Script
' Set some environment variables
oQTP.Test.Environment.Value("AppName") = "AnyWebApp"
oQTP.Test.Environment.Value("AppVersion") = "3.0"
oQTP.Test.Environment.Value("TestSuite") = "SmokeTest"
oQTP.Test.Save ' Save the test
oQTP.Quit ' Exit QuickTest
Set oQTP = Nothing ' Release the Application object
'***********************************************************
'***********************************************************
QTP - AOM - Add Shared Object Repository to QTP
'Automation Object Model
'************************************************************************
'************************************************************************
' GAReddy @ OneTestingCenter @ QTP - AOM (Automation Object Model)
' What ==> QTP - AOM Script to Open QTP and to Add Shared / Global Object Repository
' How ==> Need QuickTest.Application Automation Object to do so
' Why ==> To Open a Driver Script (which could call other tests)
' To Add shared / Global Object Repository to QTP
' To Save the test
' Author : GAReddy @ OneTestingCenter @ QTP
'************************************************************************
'************************************************************************
Dim oQTP
Dim QTPRepositories
' Open QuickTest
Set oQTP = CreateObject("QuickTest.Application") ' Create the Application object
oQTP.Launch ' Launch QuickTest
oQTP.Visible = True ' Set QuickTest to be visible
' Open a test and get the "Login" action's object repositories collection
oQTP.Open "D:\GAReddy\OneTestingCenter\QTP\AprilBatch\KeywordDrivenFramework\TestScripts\DriverScript", False, False ' Open a test
ActionName=Environment.Value("ActionName")
Set QTPRepositories = oQTP.Test.Actions(ActionName).ObjectRepositories
' Get the object repositories collection object of the "Login" action
' Add MainApp.tsr if it's not already in the collection
If QTPRepositories.Find("D:\GAReddy\OneTestingCenter\QTP\AprilBatch\KeywordDrivenFramework\ObjectRepository\GlobalOR.tsr") = -1 Then
' If the repository cannot be found in the collection
QTPRepositories.Add "D:\GAReddy\OneTestingCenter\QTP\AprilBatch\KeywordDrivenFramework\ObjectRepository\GlobalOR.tsr", 1
' Add the repository to the collection
End If
'Save the test and close QuickTest
oQTP.Test.Save ' Save the test
oQTP.Quit ' Quit QuickTest
Set QTPRepositories = Nothing ' Release the action's shared repositories collection
Set oQTP = Nothing ' Release the Application object
'************************************************************
'*************************************************************
QTP - AOM - Add Functional Libraries - Run Tests - Save Results
'Automation Object Model
'************************************************************************
'************************************************************************
' GAReddy @ OneTestingCenter @ QTP - AOM (Automation Object Model)
' What ==> This is a QTP - AOM Script to Open QTP , To Open Driver Script, To Add the functional LIBs to QTP and to Run the Test
' and store the results on to specified results directory (using the Run options)
' How ==> Need QuickTest.Application Automation Object to do so
' Why ==> To Open a Driver Script (which could call other tests)
' To Add the Functional Library files to QTP
' To Run the tests
' To Save the test results
' Author : GAReddy @ OneTestingCenter @ QTP
'**********************************************************************
'*******************************************************************
Dim oQTP
Dim QTPLibraries
' Open QuickTest
Set oQTP = CreateObject("QuickTest.Application") ' Create the Application object
oQTP.Launch ' Launch QuickTest
oQTP.Visible = True ' Set QuickTest to be visible
' Open a test and get its libraries collection
oQTP.Open "D:\GAReddy\OneTestingCenter\QTP\AprilBatch\KeywordDrivenFramework\TestScripts\DriverScript", False, False ' Open a test
Set QTPLibraries = oQTP.Test.Settings.Resources.Libraries ' Get the libraries collection object
' To check if the LIBs are added to QTP..If not ...add them
'If QTPLibraries.Find("D:\GAReddy\OneTestingCenter\QTP\AprilBatch\KeywordDrivenFramework\LIBs\TO_WebEdit.vbs") = -1 Then
' If the library cannot be found in the collection
' QTPLibraries.Add "D:\GAReddy\OneTestingCenter\QTP\AprilBatch\KeywordDrivenFramework\LIBs\TO_WebEdit.vbs", 1
' Add the library to the collection
'End If
' To add functional LIBs to QTP
QTPLibraries.Add "D:\GAReddy\OneTestingCenter\QTP\AprilBatch\KeywordDrivenFramework\LIBs\TO_WebEdit.vbs", 1
QTPLibraries.Add "D:\GAReddy\OneTestingCenter\QTP\AprilBatch\KeywordDrivenFramework\LIBs\TO_WebButtonvbs", 1
QTPLibraries.Add "D:\GAReddy\OneTestingCenter\QTP\AprilBatch\KeywordDrivenFramework\LIBs\TO_Link.vbs", 1
QTPLibraries.Add "D:\GAReddy\OneTestingCenter\QTP\AprilBatch\KeywordDrivenFramework\LIBs\Image.vbs", 1
QTPLibraries.Add "D:\GAReddy\OneTestingCenter\QTP\AprilBatch\KeywordDrivenFramework\LIBs\Generic.vbs", 1
QTPLibraries.Add "D:\GAReddy\OneTestingCenter\QTP\AprilBatch\KeywordDrivenFramework\LIBs\Driver.vbs", 1
Set QTPResultsOptions = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object
QTPResultsOptions.ResultsLocation = "D:\GAReddy\OneTestingCenter\QTP\AprilBatch\KeywordDrivenFramework\TestResults\Res1" ' Set the results location
QTPTest.Run QTPResultsOptions ' Run the test
'Save the test and close QuickTest
oQTP.Test.Save ' Save the test
Set QTPLibraries = Nothing ' Release the test's libraries collection
oQTP.Quit ' Quit QuickTest
Set oQTP = Nothing ' Release the Application object
'************************************************************************
'************************************************************************
QTP - AOM - Open Driver Sctipt - Run Tests - Save Results
'Automation Object Model
'*******************************************************************
'*******************************************************************
' GAReddy @ OneTestingCenter @ QTP - AOM (Automation Object Model)
' What ==> This is a QTP - AOM Script to Open QTP , To Open Driver Script (To Open Existing Script ) and to Run the Test
' and store the results on to specified results directory (using the Run options)
' How ==> Need QuickTest.Application Automation Object to do so
' Why ==> To Open a Driver Script (which could call other tests) and to Run Automatically
' Author : GAReddy @ OneTestingCenter @ QTP
'******************************************************************
'******************************************************************
Dim oQTP
Dim QTPTest
Dim QTPResultsOptions
Set oQTP = CreateObject("QuickTest.Application") ' Create the Application object
oQTP.Launch ' Start QuickTest
oQTP.Visible = True ' Make the QuickTest application visible
' Set QuickTest run options
oQTP.Options.Run.ImageCaptureForTestResults = "OnError"
oQTP.Options.Run.RunMode = "Fast"
oQTP.Options.Run.ViewResults = False
oQTP.Open "D:\GAReddy\OneTestingCenter\QTP\AprilBatch\KeywordDrivenFramework\TestScripts\DriverScript", True
' Open the test in read-only mode
' set run settings for the test
Set QTPTest = oQTP.Test
QTPTest.Settings.Run.OnError = "NextStep"
' Instruct QuickTest to perform next step when error occurs
Set QTPResultsOptions = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object
QTPResultsOptions.ResultsLocation = "D:\GAReddy\OneTestingCenter\QTP\AprilBatch\KeywordDrivenFramework\TestResults\Res1"
' Set the results location
QTPTest.Run QTPResultsOptions ' Run the test
MsgBox QTPTest.LastRunResults.Status ' Check the results of the test run
QTPTest.Close ' Close the test
Set QTPResultsOptions = Nothing ' Release the Run Results Options object
Set QTPTest = Nothing ' Release the Test object
Set oQTP = Nothing ' Release the Application object
'*********************************************************************
'*********************************************************************
Subscribe to:
Posts (Atom)