Object Models in QTP / UFT - Part 1 COM

Four different types of Object Models we will discuss:

1.    Component Object Model ( COM )
2.    Document Object Model ( DOM )
3.    Test Object Model ( TOM )
4.    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

Example:- Applications involved are Excel objects, FSO File System objects


1.    CreateObject 
2.    GetObject
3.    Set 

·         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

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

*Note : ABI Application Binary interface is the interface between two program modules, library or operating system, at the level of machine code .
ABI differs from API i.e. Application Programming interface (APIs), which similarly define interfaces between program components, but at the source code level.