object spy in QTP

By | July 14, 2009

Object spy in QTP

Object spy is the very much important tool in qtp. With the use of Object spy we can learn basic structure of test object. The main advantage of object spy is that we can see object structure of specific object in tree view. So that makes test object more understandable and easier.

In addition to this we can view the run-time and test object properties and methods of any object in open application.

Now let’s understand and use object spy practically.

How to use Object spy in qtp?

1. Go to Tools->Object spy.
2. One window named Object Spy will open
3. Then open the application whose object properties or methods you want to see.
4. Then just click on “Pointer image” of object spy window.
5. Click on Object whose object properties or methods you want to see.

Above figure is window of object spy. I have used “object Spy” tool on “google.com” logo “Google’. QTP recognize this logo “Google” as image. Using Object spy you can view two things one is properties of specific object and second is methods applicable for that object.

Use of Object spy:

– You can view different object properties of selected objects.
– Let’s see some example, you can know file name of image see in fig. “logo.gif”
– You can see link of the image like “http://www.google.com/intl/en_ALL/images/logo.gif” so in short you can view all object properties of objects.
– You can view different methods applicable for this object using that you can access object. Like capturebitmap, click, GetROproperty, exist, drag and drop etc.
– You can also understand the basic structure of object using which QTP identifies specific object. Refer above figure for image object’s structure understanding. You can see upper part in figure, first parent object is Browser second is page and third is image. So this is how QTP writes following sentence to identify this image object.

Browser(“Google”).Page(“Google”).Image(“Google”).Click

In above sentence you can see one object method named “click” that you observed in object spy.

So I hope now you are clear how QTP understand the object.

You are always welcome to share your feedback on this post “object spy in QTP”.

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

10 thoughts on “object spy in QTP

  1. Anonymous

    Hi you,
    I use object spy but it can’t recognize controls on web such as links, images and their properties, it only recognizes window controls and browser. How can I fix it? Which operation was it wrong in my installation?
    Please help me, thank a lot.

    Reply
  2. visitjaga

    Hi,

    Is it possible to add objects to a object repository automatically(using vb scripts) ? . Lets say I have list of links in my webpage/application.It would be time consuming,when I add objects manually so I tried to add objects to repository automatically.But couldn’t able to proceed as I don’t know how to activate object repository window in qtp. Below is my code which I tried

    Function Objects_Count(myObject)
    Dim Objects
    Set Objects=Description.Create
    Objects(“micclass”).value=myObject
    set obj=Browser(“title:=.*”).Page(“title:=.*”).ChildObjects(Objects)
    For i=0 to obj.count-1
    ‘ msgbox i
    c=obj(i).getroproperty(“name”)
    If obj(i).Exist(1) Then
    obj(i).highlight
    End If
    Print c
    Next
    End Function
    Call Objects_Count(“link”)

    The above code will get the links name displayed in a log file and also it will highlight in application/webpage. Please guide me ,how to add the properties of that links(objects) to object repository.

    Thanks! visitjaga@gmail.com

    Reply
  3. visitjaga

    Hi,

    Is it possible to add objects to a object repository automatically(using vb scripts) ? . Lets say I have list of links in my webpage/application.It would be time consuming,when I add objects manually so I tried to add objects to repository automatically.But couldn’t able to proceed as I don’t know how to activate object repository window in qtp. Below is my code which I tried

    Function Objects_Count(myObject)
    Dim Objects
    Set Objects=Description.Create
    Objects(“micclass”).value=myObject
    set obj=Browser(“title:=.*”).Page(“title:=.*”).ChildObjects(Objects)
    For i=0 to obj.count-1
    ‘ msgbox i
    c=obj(i).getroproperty(“name”)
    If obj(i).Exist(1) Then
    obj(i).highlight
    End If
    Print c
    Next
    End Function
    Call Objects_Count(“link”)

    The above code will get the links name displayed in a log file and also it will highlight in application/webpage. Please guide me ,how to add the properties of that links(objects) to object repository.

    Thanks! visitjaga@gmail.com

    Reply
  4. visitjaga

    Is it possible to add objects to a object repository automatically(using vb scripts) ? . Lets say I have list of links in my webpage/application.It would be time consuming,when I add objects manually so I tried to add objects to repository automatically.But couldn’t able to proceed as I don’t know how to activate object repository window in qtp. Below is my code which I tried

    Function Objects_Count(myObject)
    Dim Objects
    Set Objects=Description.Create
    Objects(“micclass”).value=myObject
    set obj=Browser(“title:=.*”).Page(“title:=.*”).ChildObjects(Objects)
    For i=0 to obj.count-1
    ‘ msgbox i
    c=obj(i).getroproperty(“name”)
    If obj(i).Exist(1) Then
    obj(i).highlight
    End If
    Print c
    Next
    End Function
    Call Objects_Count(“link”)

    The above code will get the links name displayed in a log file and also it will highlight in application/webpage. Please guide me ,how to add the properties of that links(objects) to object repository.

    Thanks! visitjaga@gmail.com

    Reply
  5. Rajesh Sharma

    I’ve challenge – one of the SAP app object type within the windows pop up menu is not recognised by QTP, I retrieve class and value, property using QTP SPY but now sure how to make it recognisable at run time – can someone send me function that can be used to recognise this object or any other mechanism to read value from this tiny window

    Reply
  6. Rajesh Sharma

    I’ve challenge – one of the SAP app object type within the windows pop up menu is not recognised by QTP, I retrieve class and value, property using QTP SPY but now sure how to make it recognisable at run time – can someone send me function that can be used to recognise this object or any other mechanism to read value from this tiny window

    Reply
  7. Sandeep Dahiya

    Object Spy helps in determining the run & test time object properties & methods of the application under test.

    You can access object spy directly from the toolbar or from the Object Repository Dialog Box.

    It is very useful during Descriptive Programming

    Reply

Leave a Reply

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