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 identification. Show all posts
Showing posts with label object identification. Show all posts

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.

GetRoProperty In QTP Continued

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 VbEditor test object supports the identification properties listed in the table below.



Property Name

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).

alignment

Indicates the object's alignment or the alignment of the text in the object.

Possible values:

0 (VbLeftJustify): Text is left-aligned.
1 (VbRightJustify): Text is right-aligned.
2 (VbCenter): Text is centered.

attached text

The static text that is attached to a control.

BackColor

The background color of an object.

BorderStyle

The object's border style.

Class Name

The object's class.

column

The x-coordinate of the cursor in the object (in number of characters).

enabled

Indicates whether the object is enabled.

Possible values:                                  
       True       False

focused

Indicates whether the object has the focus.

Possible values:                                  
       True       False

FontBold

Indicates whether the font style is bold.

Possible values:                                  
       True       False (Default)

FontItalic

Indicates whether the font style is italic.

Possible values:                                  
       True       False (Default)

FontName

The font used to display text in the control.

FontSize

The size (in points) of the font used for text displayed in the control.

FontStrikethru

Indicates whether the font style is strikethrough.

Possible values:                                  
       True       False (Default)

FontUnderline

Indicates whether the font style is underlined.

Possible values:                                  
       True       False (Default)

ForeColor

The color of the object's text.

HasHScroll

Indicates whether the object has a horizontal scroll bar.

HasVScroll

Indicates whether the object has a vertical scroll bar.

height

The object's height (in pixels).

HideSelection

Indicates whether selected text appears highlighted when the control loses the focus.

Possible values:                                  
       True       False

HScrollPageSize

The horizontal page size. The scroll bar uses this value to determine the approximate size of the scroll box. If the object does not have a scroll bar, the GetROProperty method returns an empty value for this property.

HScrollPosition

The position of the horizontal scroll box. If the object does not have a scroll bar, the GetROProperty method returns an empty value for this property.

hWnd

The handle of the run-time object's window.

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.

left

The distance between the internal left edge of an object and the left edge of its container.

LeftScrollbar

Indicates whether the vertical scroll bar is positioned on the left of the object.

line

The y-coordinate of the cursor in the object (in number of lines).

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.

locked

Indicates whether the control can be edited.

Possible values:                                  
       True       False (Default)

MaxHScrollPos

The maximum horizontal scrolling position. If the object does not have a scroll bar, the GetROProperty method returns an empty value for this property.

MaxLength

The maximum number of characters that can be entered into the edit box.

MaxVScrollPos

The maximum vertical scrolling position. If the object does not have a scroll bar, the GetROProperty method returns an empty value for this property.

MinHScrollPos

The minimum horizontal scrolling position. If the object does not have a scroll bar, the GetROProperty method returns an empty value for this property.

MinVScrollPos

The minimum vertical scrolling position. If the object does not have a scroll bar, the GetROProperty method returns an empty value for this property.

MultiLine

Indicates whether the control can accept and display multiple lines of text.

Possible values:                                  
       True       False (Default)

name

The object's name.

NativeClass

The object's window class name.

PasswordChar

The characters typed by a user, or placeholder characters in the edit box.

RegExpWndClass

The permanent part of the MFC window class.

RegExpWndTitle

The constant part of the window title.

RightToLeft

Indicates the display direction and visual appearance of the text on a bi-directional system.

Possible values:

True: The control runs on a bi-directional platform and text runs from right to left. The control modifies its behavior, such as putting vertical scroll bars at the left side of a text or list box, putting labels to the right of text boxes, etc.

False: (Default) The control act as though it were running on a non-bidirectional platform and text runs from left to right.

ScrollBars

Indicates whether an object has vertical or horizontal scroll bars.

Possible values:

0 (vbSBNone): None
1 (vbHorizontal): Horizontal
2 (vbVertical): Vertical
3 (vbBoth): Both

SelLength

The number of characters selected.

SelStart

The starting point of the selected text; indicates the position of the insertion point if no text is selected.

SelText

The string containing the currently selected text; consists of a zero-length string ("") if no characters are selected.

TabIndex

The tab order of the object within its parent form.

TabStop

Indicates whether a user can use the Tab key to give the focus to the object.

Possible values:                                  
       True (Default)
       False

tag

An expression that stores any extra data needed for your program. This property is generally used to identify objects.

TestObjGenType

The object's generic type, for example, text box, list box, or table.

TestObjName

The object's name as it appears in the object repository. This property cannot be used with programmatic descriptions or as a description property for the ChildObjects method.

If the object is not found in the object repository, the TestObjName is defined as follows:


  • If the object is found in the application, QuickTest uses the value of the property it normally uses when adding this object to the object repository, surrounded by [ ].


  • If the object is not found in the application, QuickTest uses the value of the object's Class Name property, surrounded by [ ].

text

The text associated with the object.

top

The distance between the internal top edge of an object and the top edge of its container.

vbname

The object's name as set by the developer.

vbname path

The full hierarchy of vbname with all parent objects.

visible

Indicates whether the object is visible.

Possible values:                                  
       True       False

VScrollPageSize

The vertical page size. The scroll bar uses this value to determine the approximate size of the scroll box. If the object does not have a scroll bar, the GetROProperty method returns an empty value for this property.

VScrollPosition

The position of the vertical scroll box. If the object does not have a scroll bar, the GetROProperty method returns an empty value for this property.

width

The object's width (in pixels).

window id

The object's window identifier.

WindowExtendedStyle

The extended window style of the object.

WindowStyle

The window style of the object.

x

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

y

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


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

GetRoProperty In QTP

How To : Performing Programmatic Description Checks


You can compare the run-time value of a specified object property with the expected value of that property using either programmatic descriptions or user-defined functions.

Programmatic description checks are useful in cases in which you cannot apply a regular checkpoint, for example, if the object whose properties you want to check is not stored in an object repository. You can then write the results of the check to the Test Results report.

For example, suppose you want to check the run-time value of a Web button. You can use the GetROProperty or Exist operations to retrieve the run-time value of an object or to verify whether the object exists at that point in the run session.

The following examples illustrate how to use programmatic descriptions to check whether the Continue Web button is disabled during a run session.

Using the GetROProperty operation:

ActualDisabledVal = Browser(micClass:="Browser").Page(micClass:="Page").WebButton(alt:="Continue").GetROProperty("disabled")

Using the Exist operation:

While Not Browser(micClass:="Browser").Page(micClass:="Page").WebButton(alt:="Continue").Exist(30)

Wend

By adding Report.ReportEvent statements, you can instruct QuickTest to send the results of a check to the Test Results.

If ActualDisabledVal = True Then

Reporter.ReportEvent micPass, "CheckContinueButton = PASS", "The Continue button is disabled, as expected."

Else

Reporter.ReportEvent micFail, "CheckContinueButton = FAIL", "The Continue button is enabled, even though it should be disabled."

You can also create and use user-defined functions to check whether your application is functioning as expected. The following example illustrates a function that checks whether an object is disabled and returns True if the object is disabled:

'@Description Checks whether the specified test object is disabled

'@Documentation Check whether the is enabled.

Public Function VerifyDisabled (obj)

       Dim enable_property

       ' Get the disabled property from the test object

       enable_property = obj.GetROProperty("disabled")

       If enable_property = 1 Then ' The value is True (1)—the object is disabled

              Reporter.ReportEvent micPass, "VerifyDisabled Succeeded", "The test object is disabled, as expected."

              VerifyDisabled = True

       Else

              Reporter.ReportEvent micFail, "VerifyDisabled Failed", "The test object is enabled, although it should be disabled."

              VerifyDisabled = False

       End If

End Function 

Retrieving Native Properties


You can use the Object property to access the native properties of any run-time object. For example, you can retrieve the current value of the ActiveX calendar's internal Day property as follows:

Dim MyDay

Set MyDay=Browser("index").Page("Untitled").ActiveX("MSCAL.Calendar.7").Object.Day


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

Resources Menu Commands In QTP

Resources Menu Commands


You can manage your object repositories and other resources using the following Resources menu commands:




Command

Shortcut Key

Function

1
Object Repository

Ctrl+R

Opens the Object Repository window, which displays a tree containing all objects in the current test or component.

2

Object Repository Manager

Opens the Object Repository Manager dialog box, enabling you to open and modify multiple shared object repositories.

3

Associate Repositories

Opens the Associate Repositories dialog box, enabling you to manage the object repository associations for the test.

4

Map Repository Parameters

Opens the Map Repository Parameters dialog box, enabling you to map repository parameters, as needed.
 5
Recovery Scenario Manager

Opens the Recovery Scenario Manager dialog box.
 6
Associated Function Libraries

Lists the function libraries associated with the active document, enabling you to open them.



The Object Repository menu command is also available from the Automation toolbar.


For gaining more insights in the automation using QTP log on to below url :
Automation Testing Using QTP

Resolving Object Conflicts In Object Repository Merging In QTP


Understanding Object Conflicts In QTP


Merging two object repositories can result in conflicts arising from similarities between the objects they contain. The Object Repository Merge Tool identifies three possible conflict types:

  •  Similar Description Conflict. Two objects that have the same name and the same object hierarchy, but that have slightly different descriptions. In this conflict type, one of the objects always has a subset of the properties set of the other object.
  • By default, the conflict resolution settings for conflicts of this type are configured so that the target object repository takes the object that has fewer identifying properties than the object with which it conflicts. For information on changing the default settings, see Defining Default Settings.

  •  Same Name Different Description Conflict. Two objects that have the same name and the same object hierarchy, but differ somehow in their description (for example, they have different properties, or the same property with different values).
  • By default, the conflict resolution settings for conflicts of this type are configured so that the target object repository takes the object from both files. The object that is added from the secondary file is renamed by adding an incremental numeric suffix to the name, for example, Edit_1. For information on changing the default settings, see Defining Default Settings.

  •  Same Description Different Name Conflict. Two objects that have identical descriptions and have the same object hierarchy, but differ in their object names.
  • By default, the conflict resolution settings for conflicts of this type are configured so that the target object repository takes the object name from the primary source file. For information on changing the default settings, see Defining Default Settings.
    Note: Objects that do not have a description, such as Page or Browser objects, are compared by name only. If the same object is contained in both the source object repositories but with different names, they will be merged into the target object repository as two separate objects.

Similar Description Conflict

An object in the primary object repository and an object in the secondary object repository have the same name, and they have similar, but not identical, description properties and values. One of the objects always has a subset of the properties set of the other object. For example, an object named Button_1 in the secondary object repository has the same description properties and values as an object named Button_1 in the primary object repository, but also has additional properties and values.

You can resolve this conflict type by:

  • Keeping the object added from the primary object repository only.

  • Keeping the object added from the secondary object repository only.

  • Keeping the objects from both object repositories. In this case, the Object Repository Merge Tool automatically renames the object that is added from the secondary file by adding an incremental numeric suffix to the name, for example, Edit_1.

  • Ignoring the object from the local object repository and keeping the object from the shared object repository (when updating a shared object repository from a local object repository).

Same Name Different Description Conflict

An object in the primary object repository and an object in the secondary object repository have the same name, but completely different description properties and values.

You can resolve this conflict type by:

  • Keeping the object added from the primary object repository only.

  • Keeping the object added from the secondary object repository only.

  • Keeping the objects from both object repositories. In this case, the Object Repository Merge Tool automatically renames the object that is added from the secondary file by adding an incremental numeric suffix to the name, for example, Edit_1.

  • Ignoring the object from the local object repository and keeping the object from the shared object repository (when updating a shared object repository from a local object repository).

Same Description Different Name Conflict

An object in the primary object repository and an object in the secondary object repository have different names, but the same description properties and values.

You can resolve this conflict type by:

  • Taking the object name from the object in the primary object repository.

  • Taking the object name from the object in the secondary object repository.

  • Ignoring the object from the local object repository and keeping the object from the shared object repository (when updating a shared object repository from a local object repository).
Resolving Object Conflicts

Conflicts between objects in the primary and secondary object repositories are resolved automatically by the Object Repository Merge Tool according to the default resolution settings that you can configure before performing the merge. For more information, see Defining Default Settings.

However, the Object Repository Merge Tool also allows you to change the way the merge was performed for each individual object that causes a conflict.

For example, an object in the primary object repository could have the same name as an object in the secondary object repository, but have a different description. You may have defined in the default settings that in this case, the object with the more generic object description, meaning the object with fewer properties, should be added to the target object repository. However, when you review the conflicts after the automatic merge, you could decide to handle the specific conflict differently, for example, by keeping both objects.

Note: Changes that you make to the default conflict resolution can themselves affect the target object repository by causing new conflicts. In the above example, keeping both objects would cause a name conflict. Therefore, the target object repository is updated after each conflict resolution change and redisplayed.

You can identify objects that caused conflicts, and the conflict type, by the icon displayed to the left of the object name in the target object repository pane of the Object Repository Merge Tool and the text color. When you select a conflicting object, a full description of the conflict, including how it was automatically resolved by the Object Repository Merge Tool, is displayed in the Resolutions Options pane.

The Resolutions Options pane offers alternative resolution options. You can choose to keep the default resolution if it suits your needs, or use the alternative options to resolve the conflict in a different way. In addition, for a local object repository merge, you can click the Ignore Object button to exclude a specific local object repository object from the target shared object repository.

Tip: You can also change the default resolution settings and merge the files again. For more information, see Defining Default Settings.

To change the way in which object conflicts are resolved:

  1. In the target object repository, select an object that had a conflict, as indicated by the icon to the left of the object name. The conflicting objects are highlighted in the source object repositories.
  2. A description of the conflict and the resolution method used by the Object Repository Merge Tool is described in the Resolution Options pane. A radio button for each possible alternative resolution method is displayed. For information on each of the conflict types, see Understanding Object Conflicts.

  3. In the Resolution Options pane, select a radio button to choose an alternative resolution method. The target object repository is updated according to your selection and redisplayed.

  4. In the Resolution Options pane, click the Previous Conflict or Next Conflict buttons to jump directly to the next or previous conflict in the target object repository hierarchy.

  5. Repeat steps 1 to 3 to modify additional conflict resolutions, as necessary.

  6. Save the target object repository, as described in Saving the Target Object Repository.

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