Object Models in QTP - COM, DOM, AOM, TOM Part 1

What are Object Models in QTP ?


Four different types of Object Models we will discuss:

Component Object Model ( COM )
Document Object Model ( DOM )
Test Object Model ( TOM )
Automation Object Model ( AOM )
COM - Component Object Model
(examples:- Excel objects, FSO objects)

DOM - Document Object Model
(examples:- Browser("").Page("").object.getElementsByTagName)

AOM - Automation Object Model
(examples:- Createobject("quicktest.application"))

TOM - Test Object Model
(examples:- Ways and concepts to show , how QTP  handles AUT objects)

Component Object Model ( COM )
COM is an object model and an Application Binary Interface(ABI)that allows applications/objects (Excel objects, FSO objects) to interact and expose its functionality to other applications/objects (Excel objects, FSO objects) in different environments(programming language , operating systems) , by providing methods and functions to use and manipulate applications/ objects

(examples:- Applications involved are Excel objects, FSO File System Objects)

CreateObject   creates an Automation object of the specified class.
Set   statement creates the reference between the object variable and the object.
GetObject   method returns a reference to an instance of an object. It can be used in two way with its parameters, the object’s path name and the object’s ProgID.

ABIs differ from application programming interfaces (APIs), which similarly define interfaces between program components, but at the source code level.

Following code uses COM objects (Outlook application ) to send mail

'Create an object of type Outlook
Set objOut = CreateObject("Outlook.Application")
Set myOutMail = objOut .CreateItem(0)

'Set the properties of email
myOutMail .To = "example@gmail.com"
myOutMail .Subject = "Demo of COM object Outlook"
myOutMail .Body= "We are using Outlook application in COM"

'Send the mail
myOutMail .Send