Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Showing posts with label Object Properties in QTP. Show all posts
Showing posts with label Object Properties in QTP. Show all posts

Object Spy In QTP

Viewing Object Properties and Operations Using the Object Spy


Using the Object Spy pointing hand mechanism, you can view the supported properties and operations of any object in an open application. As you move the pointing hand over the objects in the application, their details are displayed in the Object Spy. These details may include the test object's hierarchy tree, its identification properties and values, and the operations associated with the object. For operations, the syntax is also displayed. For information about using the run-time object's operations or retrieving the values of its properties, see Retrieving and Setting Identification Property Values and Accessing Native Properties and Operations.

In most environments, you can choose to view the identification properties, the native properties, the test object operations, or the native operations.

To view identification properties, native properties, test object operations, or native operations:

  1. Open your application to the page containing the object on which you want to spy.

  2. Select Tools > Object Spy or click the Object Spy toolbar button  to open the Object Spy dialog box.

  3. Select the details you want to view for the object. For more information, see The Object Spy Dialog Box.

  4. If the objects on which you want to spy have a deep hierarchy, or long property names and values, resize the Object Spy dialog box to view all the information without scrolling.

  5. In the Object Spy dialog box, click the pointing hand  . QuickTest is hidden. As you move the pointing hand over the objects in your application, the objects are highlighted, and you can view their test object hierarchy and properties or operations in the Object Spy dialog box.
  6. Note: Highlighting the object in the application is supported only in some environments.
    For more information on using the pointing hand, see Tips for Working with the Pointing Hand.

  7. Hover over an object in your application. The object is highlighted in the application, and the Object Spy displays the corresponding test object, its properties or operations, and the test object hierarchy tree. You can move your mouse from one object to another in your application (without clicking) to view information on each object.
  8. To view different details about the test object in the Object Spy dialog box, hold the left Ctrl key and click the relevant options in the dialog box.
    To view the properties and operations of another test object currently displayed in the test object hierarchy tree, hold the left Ctrl key and select the relevant test object.

  9. To capture information about a particular object and its parent objects in the Object Spy, click on the object (in your application). The Object Spy displays the test object hierarchy tree and details for the selected object according to the object details tab and object type radio button that are selected.
  10. After clicking on an object, you can change the selected radio button or tab to view additional details.
    To view properties, values, or operations of other test objects currently displayed in the test object hierarchy tree, select that test object in the tree.

GetRoProperty And SetRoProperty In QTP


Retrieving and Setting Identification Property Values


More On Object Properties in QTP

The below stuff is very important and very frequently used by any QTP programmer in Object identification using QTP.


Sub GetROProperty_Example2()
'The following example uses the GetROProperty method to retrieve the row
'number of the first character in the "User" field.
row = TeWindow("TeWindow").TEScreen("Sign On").TEField("User").GetROProperty("start row")
MsgBox row

End Sub


Identification properties are the set of properties defined by QuickTest for each object. You can set and retrieve a test object's identification property values, and you can retrieve the values of identification properties from a run-time object.

When you run your test or function, QuickTest creates a temporary version of the test object that is stored in the test object repository. You can use the GetTOProperty, GetTOProperties, and SetTOProperty methods in your test or function library to set and retrieve the identification property values of the test object.

The GetTOProperty and GetTOProperties methods enable you to retrieve a specific property value or all the properties and values that QuickTest uses to identify an object.

The SetTOProperty method enables you to modify a property value that QuickTest uses to identify an object.

Note: Because QuickTest refers to the temporary version of the test object during the run session, any changes you make using the SetTOProperty method apply only during the course of the run session, and do not affect the values stored in the test object repository.

For example, the following statements would set the Submit button's name value to my button, and then retrieve the value my button to the ButtonName variable:

Browser("QA Home Page").Page("QA Home Page").WebButton("Submit").SetTOProperty "Name", "my button"

ButtonName=Browser("QA Home Page").Page("QA Home Page").WebButton("Submit").GetTOProperty("Name")

You use the GetROProperty method to retrieve the current value of an identification property from a run-time object in your application.

For example, you can retrieve the target value of a link during the run session as follows:

link_href = Browser("HP Technologies").Page("HP Technologies").Link("Jobs").GetROProperty("href")

GetRoProperty In QTP For Java Applet

What is : Object identification properties can be used in the object repository description, in programmatic descriptions, in checkpoint and output value steps, and as argument values for the GetTOProperty and GetROProperty methods.


The JavaApplet test object supports the identification properties listed in the table below. Note, however, that some of the properties may not be applicable for a specific JavaApplet object and some objects may have additional identification properties that are generated dynamically.


Property

Description

abs_x

The object's absolute x-coordinate (left) relative to the screen (in pixels).

abs_y

The object's absolute y-coordinate (top) relative to the screen (in pixels).

attached text

The static text that is attached to an object.

background

The object's background color.

class description

The general object type (i.e. list, button, table, etc...).

class_path

The Java class hierarchy of the object's Java class.

developer name

The object's internal name.

displayable

Indicates whether the object can be displayed.

Possible values:      
       0: Cannot be displayed.
       1: Can be displayed.

displayed

Indicates whether the object is displayed on the screen.

Possible values:      
       True
       False

enabled

Indicates whether the object is enabled.

Possible values:      
       True
       False

focusable

Indicates whether the focus can be set on the object.

Possible values:      
       0: The focus cannot be set on the object.
       1: The focus can be set on the object.

focused

Indicates whether the object has the focus.

Possible values:      
       True
       False

foreground

The object's foreground color.

height

The object's height (in pixels).

hwnd

The run-time object's window handle.

index

The ordinal identifier that QuickTest assigns to the object to indicate the order in which the object appears in the code relative to other objects with an otherwise identical description. This property cannot be used with GetROProperty.

Values begin with 0.

java window

Indicates whether the object is a Java window.

Possible values:      
       True
       False

label

The object's label.

location

The ordinal identifier that QuickTest assigns to the object to indicate where the object appears within the window, frame, or dialog box. Values are assigned from top to bottom, and left to right. This property cannot be used with GetROProperty.

Values begin with 0.

maximizable

Indicates whether the window is maximizable.

Possible values:      
       True
       False

maximized

Indicates whether the window is maximized.

Possible values:      
       True
       False

minimizable

Indicates whether the window is minimizable.

Possible values:      
       True
       False

minimized

Indicates whether the window is minimized.

Possible values:      
       True
       False

opaque

Indicates whether the object is transparent or opaque.

Possible values:      
       0: Transparent. Background color and any graphics are visible behind the control.
       1:
Opaque. The area behind the control is not visible.

path

The object's hierarchy (object ancestors).

resizable

Indicates whether the window is resizable.

Possible values:      
       True
       False

tagname

The test object's name.

toolkit class

The object's Java class name.

width

The object's width (in pixels).

x

The object's x-coordinate (left) relative to the parent object (in pixels).

y

The object's y-coordinate (top) relative to the parent object (in pixels).
The below stuff is very important and very frequently used by any QTP programmer in Object identification using QTP.

Manipulate Object Repositories In QTP

How to retrieve an object repository's objects and properties,
'looks for specific test objects using several methods, and copies a test object
'to another object repository.



Dim ImageObj, PageObj, RepositoryFrom, RepositoryTo

Set RepositoryFrom = CreateObject("Mercury.ObjectRepositoryUtil")
Set RepositoryTo = CreateObject("Mercury.ObjectRepositoryUtil")

RepositoryFrom.Load "C:\QuickTest\Tests\Flights.tsr"
RepositoryTo.Load "E:\Temp\Tests\Default.tsr"
Function EnumerateAllChildProperties(Root)

'The following function recursively enumerates all the test objects directly under
'a specified parent object. For each test object, a message box opens containing the
'test object's name, properties, and property values.

    Dim TOCollection, TestObject, PropertiesCollection, Property, Msg

    Set TOCollection = RepositoryFrom.GetChildren(Root)

    For i = 0 To TOCollection.Count - 1
            Set TestObject = TOCollection.Item(i)
            Msg = RepositoryFrom.GetLogicalName(TestObject) & vbNewLine
            Set PropertiesCollection = TestObject.GetTOProperties()

            For n = 0 To PropertiesCollection.Count - 1
                Set Property = PropertiesCollection.Item(n)
                Msg = Msg & Property.Name & "-" & Property.Value & vbNewLine
            Next
            MsgBox Msg

EnumerateAllChildProperties TestObject
    Next

End Function

Function EnumerateAllObjectsProperties(Root)

'The following function enumerates all the test objects under a specified object.
'For each test object, a message box opens containing the test object's name,
'properties, and property values.

 Dim TOCollection, TestObject, PropertiesCollection, Property, Msg

    Set TOCollection = RepositoryFrom.GetAllObjects(Root)

    For i = 0 To TOCollection.Count - 1
        Set TestObject = TOCollection.Item(i)
                    Msg = RepositoryFrom.GetLogicalName(TestObject) & vbNewLine

            Set PropertiesCollection = TestObject.GetTOProperties()
            For n = 0 To PropertiesCollection.Count - 1
                Set Property = PropertiesCollection.Item(n)
                Msg = Property.Name & "-" & Property.Value & vbNewLine
            Next

        MsgBox Msg
    Next

End Function

Function RenameAllImages(Root)
'The following function sets a new name for all image test objects under a specified object.
 Dim TOCollection, TestObject, PropertiesCollection, Property

    Set TOCollection = RepositoryTo.GetAllObjectsByClass("Image")

    For i = 0 To TOCollection.Count - 1
            Set TestObject = TOCollection.Item(i)
            RepositoryTo.RenameObject (TestObject, "Image " & i)
            RepositoryTo.UpdateObject TestObject
    Next

End Function

Function RemoveAllLinks(Root)
'The following function recursively enumerates all the test objects under a specified object.
'It looks for all test objects of class Link and removes them from their parent objects.

    Dim TOCollection, TestObject, PropertiesCollection, Property

    Set TOCollection = RepositoryFrom.GetChildren(Root)

    For i = 0 To TOCollection.Count - 1
            Set TestObject = TOCollection.Item(i)
            TOClass = TestObject.GetTOProperty("micclass")

         If TOClass = "Link" Then
                RepositoryFrom.RemoveObject Root, TestObject
            End If

        EnumerateAllChildProperties TestObject
    Next

End Function