What is QuickTest Automation Object Model?
It’s a way to write scripts so as to automate your UFT/QTP operations. For example: Using AOM you can launch UFT without double clicking the desktop icon.
What are some places where we can use AOM in UFT?
This is a small list of places (but not limited to) where we can use AOM. Thumb Rule – Use it at any place where you find yourself doing repetitive tasks while using UFT/QTP.
- AOM can come handy when you have a large no of scripts to be uploaded to QC. A simple script can save you hours of manual work!
- Use AOM to initialize QTP options and settings like add-ins etc.
- You can use AOM to call QTP from other application: For ex: You can write a macro for calling QTP from excel.
Caution: AOM should be used outside of QTP and not within the script (during playback). Though there is no harm using it inside but some of the AOM statements might fail.
How to write AOM scripts?
You need to understand that the very root of QT AOM is Application
Object. Every automation script begins with the creation of the QuickTest Application object.
Creating this object does not start UFT. It simply provides an object from which you can access all other objects, methods and properties of the UFT/QTP automation object model.You can create only one instance of the Application object. You do not need to recreate the UFT/QTP Application object even if you start and exit UFT several times during your script.
Once you have defined this object you can then successfully work and perform operations on other objects given in UFT One Automation Object Model Reference.
For ex: Let us connect to ALM using AOM and launch a script qtp_demo
Dim qt_obj 'Define a UFT object qt_obj = CreateObject("QuickTest.Application") ' Instantiate a QT Object. It does not start QTP. qt_obj.launch ' Launch UFT qt_obj.visible ' Make UFT visible qt_obj.TDConnection.Connect "http://tdserver/tdbin", _ 'Referencing TDConnection Object "TEST_DOMAIN", "TEST_Project", "Ankur", "Testing", False ' Connect to Quality Center If qt_obj.TDConnection.IsConnected Then ' If connection is successful qt_obj.Open "[QualityCenter] Subjecttestsqtp_demo", False ' Open the test Else MsgBox "Cannot connect to Quality Center" ' If connection is not successful, display an error message. End If
To quickly generate an AOM script with the current QTP settings. Use the Properties tab of the Test Settings dialog box (File > Settings) OR the General tab of the Options dialog box (Tools > Options) OR the Object Identification dialog box (Tools > Object Identification). Each contain a Generate Script
button. Clicking this button generates an automation script file with extension .vbs
containing the current settings from the corresponding dialog box.
You can run the generated script as is to launch UFT/QTP with the exact configuration of the UFT/QTP application that generated the script, or you can copy and paste selected lines from the generated files into your own automation script.
Hi. I have need to run automated tests from Alm but the call he makes to UFT needs to be made with diferent user(run as) . Anyway to achieve this in configuration ?
Thanks in advance
Hi, I had a question.
So I have a script which connects to QC and opens a test in UFT and runs it. The problem with this is that the open command closes the previously opened tests. I want to copy the file -> add -> existing test functionality in my vbScript.
How can this be done?
very helpful article Sir!!!
keep it up…
extremely helpful, Thanks Ankur
Hi, What is the use of AOM Topic.
Can u maintain the topics in one by one
Thank a million ankur………
Hi Ankur,
Have a query reg. the AOM. I have written a vbs file to launch qtp, connect to QC, download a specific test from QC, Run the script and update the test results in QC.
I am successful in saving the test results in a particular test instance under a test set. But this works for the first time.
When I run the script for the second time, my requirement is to create a second instance and update the test results there.
Currently, a new run has been created within the first test instance.
Please guide how to do the same using AOM.
Thanks in advance!
can u share how to run a test which is in QC/ALM
I am getting error – not able to open test. Not sure if the line ObjQTP.Open “[ALM] Components/IHub/IHub Run/TestDD” is correct or not
Set ObjQTP = CreateObject(“QuickTest.Application”)
ObjQTP.Launch
ObjQTP.Visible = “True”
If Not ObjQTP.TDConnection.IsConnected Then
ObjQTP.TDConnection.Connect “http://cdlautowfnalm/qcbin/”,”I_HUB”,”Release4_1″,”ginnev”,”vg512013″,False
End If
ObjQTP.Open “[ALM] Components/IHub/IHub Run/TestDD”
Set ObjQTPTest = ObjQTP.Test
ObjQTPTest.Run
ObjQTPTest.Close
ObjQTPTest = Nothing
ObjQTP = Nothing
Hello Ankur Sir,
I am beginner in QTP. Sir, You help me on QTP project checking steps. Please sir..
-Nitin
Hi Ankur,
Your blog is great.
I have a small question but I am not able to launch QTP using AOM.The rest of the commands worked fine.
Can you help
Hi Ankur,
Thanks for posting the great article. I have one question. How to remove the existing setup and add new setup to a QTP test during Runtime using AOM from with in QTP. Generate script is giving App.Folders.RemoveAll but this line gives error if executed from within QTP.
Is there any other way of adding by removing the old ones from within QTP? Plese help..
Thanks In Advance,
Manjunath
Hi Ankur,
Thanks a ton for publishing the articles in your block. But I’ll be needing your help in one of the testing with QTP, wherein we are testing for the SAP module- FICO. This is an upgrade activity and we are not using ‘eCatt’ the most likely testing tools by SAP.
Can you please share your advise on the same, how should we go about it? And how one can identify the reusable Item simply by checking the T-codes.
Thanks,
Abhi
Hi Ankur,
This blog is great…It really helped me in a great extent when I worked on automation framework for my project.
thanks a lot
Cheers
Shruthi
Hi All,
Tell me please how I can get instance of QTP which it already ran?(inside QTP)
The main idea is to connect to QC without using QCUtil object.(QCUtil object is using already prepared QCConnection). That is why I’m trying to connect using TDConnection Object.
Thanks in advance
It’s Really good one. Special Thanks to Ankur and Our QTP Forum members.
Hi Ankur,
Your blog is helping lot of aspiring Testing professionals like me. Thanks a lot for that.
Vamsi.
I must really thank the one who started this forum. You are real Gem. I am sure thousands of testing professinals aspiring career whould be getting benifitted from this forum.
I request all the guys benifitted from this forum must than the genius who is sharing the treasure of knowledge.