How to add object repository in qtp

By | July 13, 2009

How to add object repository in qtp

Hi friends, I got very good response from you on my previous post “object repository in qtp”. So today also I am going to give you some advance knowledge in context to object repository in QTP.
I am going to teach you two following things in context to object repository.

1. How to add object repository in qtp manually.
2. How to add or load object repository in qtp during runtime.

Procedure to add object repository in qtp manually

1. Go to Edit->Action->Action Properties window.
2. Than switch to “Associated Repositories” Tab.
3. Click on “+” sign.
4. Now click on right most side button and add object repository file (in .tsr format)

Note: If you don’t know how to export object repository in .tsr file. Please refer 6th question of this post: QTP FAQS with answers part- 2

Procedure to add object repository in qtp during run time:

Just write following lines of code in your script.
——————————————————————————–

Dim qtApp

Set qtApp = CreateObject(“QuickTest.Application”)

qtApp.Test.Actions(1).ObjectRepositories.Add “C:\Repository1.tsr”
———————————————————————————

Note: Above script will add “Repository1.tsr” file to your test during run time. Please note that this object repository file will be loaded during run time so you can see it attached only during run time. During stop mode you will not be able to see attached object repository.

If you want to verify that object repository is added or not during runtime you can verify. When your script is in running mode just Go to Debug->Pause and then you can verify by going to Edit->Action->Action Properties and then associated repository tab.

So Enjoy Learning and let me know if you face any kind of difficulty. You are always welcome to share your feedback on this post “how to add object repository in qtp”.

If you like this article, You can subscribe through mail.

8 thoughts on “How to add object repository in qtp

  1. Geetha

    Hi,

    yes agreed we can add object repository as specified above. But how to add objects to the object reposityor in run time. Can you please let me know I am really looking for this solution.
    Ex:- In my screen so many check boxes are there how to add them.

    Reply
  2. muthu

    Hi i am getting a error message as

    Dim qtApp ‘As Application
    Set qtApp = CreateObject(“QuickTest.Application”)
    qtApp.Launch
    qtApp.Visible = True
    qtApp.Test.Action1.ObjectRepository.Add “D:\QTPFiles\ISMS.tsr”

    It shows an error message as Activex compnet cant creat object

    Reply
  3. muthu

    Dim qtApp ‘As Application
    Set qtApp = CreateObject(“QuickTest.Application”)
    qtApp.Launch
    qtApp.Visible = True
    qtApp.Test.Action1.ObjectRepository.Add “D:\QTPFiles\ISMS.tsr”

    When i execute this code it shows an error message as Activex component cannt create object quicktest application

    Reply
  4. priyanka

    Hi,

    Instead of specifying a particular path of Object Repository , can we use regular expression for specifying path . For eg I wolud like QTP to find path of Resource.tsr anywhere in C: drive .

    Reply
  5. qtp-fan

    @Geetha, As far as my knowledge is concern, you can change properties of object using settoproperty method,
    but you can’t add objects during run time.
    If Anyone have idea than please share with us.

    @muthu,
    Please try following code,

    Dim qtApp ‘As Application
    Set qtApp = CreateObject(“QuickTest.Application”)
    qtApp.Launch
    qtApp.Visible = True
    qtApp.Test.Actions(1).ObjectRepositories.Add “D:\QTPFiles\ISMS.tsr”

    Let me know if you are still facing the issue or not.

    Reply
  6. qtp-fan

    @Priyanka,

    You can get current path of test directory run time using built-in enivornment method (using TestDir).
    and after that you can choose your path where .tsr is stored.

    But you want anywhere in c: drive that i also haveto look for solution, If you guys have any solution for this than please share with us.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *