Automation Object Model

AOM Scripting (Automation Object Model)

Object Model:

An object model is a structural representation of software objects (classes) that comprise the implementation of a system or application. An object model defines a set of classes and interfaces, together with their properties, methods and events, and their relationships. 


We can use QTP Automation object Model to write scripts, that automate our QTP operations.

QTP Automation object model provides objects, methods and properties that enable us to control QTP from another application.

We can use Scripting languages or programming languages such as VBscript, Java script or VC++, .Net for automating QTP operations.


Example:
1) Write an AOM Script to launch QTP Tool, Execute Tests and to close the QTP Tool
option explicit
Dim qtApp
Set qtApp=createobject ("Quicktest.Application")
qtApp.Launch
qtApp.visible=True

qtApp.open "C:\Documents and Settings\admin\My Documents\login"
qtApp.Test.Run
qtApp.Test.Close

qtApp.open "C:\Documents and Settings\admin\My Documents\open order"
qtApp.Test.Run
qtApp.Test.Close

qtApp.quit
Set qtApp=Nothing

Note: AOM Script can be used in Automation framework as an Initialization script.
'------------------------------------------------------------------
 2) Write an AOM script to execute series of tests

Dim objFso,objQtp,myFile,i,gcreddy

Set objQtp = CreateObject("Quicktest.Application")
objQtp.Visible = True
objQtp.Launch

Set objFso =CreateObject("Scripting.FileSystemObject")
Set myFile = objFso.OpenTextFile("C:\Users\Chinni\Desktop\Test\gcreddy.txt")
i =1
Do Until myFile.AtEndOfStream =True
testurl =  myFile.ReadLine

objQtp.Open gcreddy
objQtp.Test.Run
objQtp.Test.Close
i = i+1
Loop

objQtp.Quit
Set objQtp = Nothing
'******************************************
G C Reddy QTP Training Program covers more scripting examples.

QTP Training Program details

0 comments:

Post a Comment