Thursday, July 14, 2011

QTP on Vista "IE7" - Not able to recognize object

You will find in most of the time that QTP will not able to recognize objects on Windows Vista or Windows 7. You may be wondering what has happened?? There are two things one should remember before automating the application is: 1. Open the Web application after you start QTP. 2. If still the error exists, and QTP is not able to recognise the objects then you need to lower down the security settings of your browser to the initial where it will allow QTP to recognise the objects.

Tuesday, July 12, 2011

AOM to load Object Repository (Shared) at Runtime. How?

Reference : HP QTP Automation Object Model - What & Why?

Now to load shared object repository runtime, we need to use the AOM approach. You can write the script inside QTP however it is not the right approach and not intended to be used this way.

Advantage: Using this approach you can import the OR just like your datatable at runtime. This will give flexibility when you are designing an automation framework

Be sure of the path of the OR 'path of shared OR tsr file' where you have saved the file

You can now add the necessary step in the generated script (in the last Script looks like in the Launch.vbs):

Script:

Dim qtApp 'Declare the application Object Variable

Dim qtObjRep 'Declare the object repository object

Set qtApp = CreateObject("QuickTest.Application") 'Creating and setting the QuickTest Application object to qtApp

Set qtObjRep = qtApp.Test.Actions().ObjectRepository 'Get the object repository collection collection object for the test action

qtObjRep.Add "Path of the Shared OR .tsr file",1

OR

qtApp.Test.Settings.Resources.ObjectRepositoryPath = “Path of the shared OR .tsr file



HP QTP Automation Object Model - What & Why?

Testers can use Quick Test Automation Object model to drive/automate the QuickTest operations/features. The Quick Test Automation Object Model (AOM) provides classes, objects, methods and their properties which enable the automation tester to control the QuickTest features from another application.

For example
If you want to invoke QTP and execute a test you would write a small invocation script to invoke and execute a test. You can also write an automation script to run selected batch of tests. Advantage : This would help me creating a testing automation framework and in test management.

Creating Automation Program
The properties tab of the test settings dialog box, the General Tab of the options dialog box and the object identification dialog box each contains a "Generate Script" button. Clicking this button and saving it would create a .vbs file containing the current test settings.

You can now run the .vbs file to invoke QTP with the exact configurations that when script is generated, or you can copy and paste the selected lines from the generated file into your own automation script.

Generating the automation script from QTP Options:
1. Go to Tools -> Options
2. Select the General Tab
3. Click Generate Script and save it as Launch.vbs (can be any name given)

Generating the automation script from the Test Settings:
1. Go to Test -> Settings
2. Select the properties Tab
3. Click on generate script and save it as Launch.vbs (can be any name given)

Generating the automation script from the object identification settings:
1. Go to Tools-> Object Identification
2. Click Generate Script and save it as Launch.vbs (can be any name given)

The QTP automation object model reference file is the help file provided by HP, that provides detailed description, syntax information and examples for the object, method and properties in the Quick Test Automation object Model.