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. Show all posts
Showing posts with label Object Properties. Show all posts

A Real life Example in QTP Identification


A Real life Example in QTP Identification: Mandatory Properties, Assistive Properties, Ordinal Identifiers.


Consider yourself as the Automation developer, myself as QTP and a parking lot as the application, cars parked in the parking area as the Test Objects.

Now you ask me (QTP) to bring a car from the parking lot and you point me to the car ( This is adding the Test Object to Object repository or recording on the same). By my previous knowledge and what I am programmed to learn, I look at the car and remember its # plate so that I can identify the same in future. The color of the car is red but I don’t remember this as # plate (My mandatory property settings) is good enough for me to recognize. This is about learning mandatory properties.

Now if I add color property to Mandatory list I will have 2 properties for identifying the car. If the car is painted to white color I would not be able to locate the car as I am still looking for a red color car with the same # plate as the white one in front of me. So this is why we don’t add all properties to Mandatory list
Now let assume this parking lot has some new cars which has no # plates. So my mandatory properties doesn’t give me anything to re-identify the car later. I start looking at my assistive properties which is the color in this case. The parking lot has only 1 red car so I remember the color as well to re-identify the car. This is about learning assistive properties. If one assistive property doesn’t help I would look at others one by one.

So far so good. Now if we have another red car parked in the parking, so my identification of blank #plate and red color will still not resolve which car to pick. So I need to make a choice based on 1st or the 2nd one (index), left one or the right one (location), the car that came first in the parking lot or the one came later (creationtime in case of browser). This is where we need ordinal identifier.

Now coming to smart identification. Consider you told me to pick a red color car with some plate #X and car was repainted to white. Now I don’t find anything in the lot and I start getting smart. I would say lets just drop off all what you said and see if I can find the car. I first see how many cars in the lot, If there is only 1 then my issue is solved. But lets say there are 3 cars, Now my SI algo says to look for the #plate and i find that white car matches the # plate so I pick it up and the car for you. This is what is Smart Identification.

If my Smart identification had color as the first property to be checked then I would have looked only at white car present in the parking lot, if I found one I would give the same to you. Even though our car may not be present in the parking lot I still give you a car which may not be the one you were looking for. This is why it always advised to keep Smart Identification disabled.

Coming back to the QTP world I would like to highlight another point now. Mandatory, Assistive properties only come into picture when we add an object to the OR or record some action on the same. While identifying the object again QTP will not differentiate which property was a Mandatory one or Assistive one. It would just try to match all the properties it had been given to identify the object.

There is a small difference when it comes to ordinal identifiers. QTP only uses ordinal identifiers when there are multiple matches of an object. So Browser(”creationtime:=50) is same as Browser(”micclass:=Browser”) when you only have one browser open as QTP will not use the Creationtime property at all. But when 2 browsers exist QTP will throw an error as there is none with creationtime:=50

I hope this cleared all doubts about these different properties are used in QTP to add and identify the object later.

Browse more on Object properties
Using Qtp Efficiently
QTP Object Properties
Qtp Object Repository

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

Object Repository In QTP 10.0

Object Repository Enhancements :

24. Ability to create and load OR’s from QTP script itself.

25. Ability to load Shared ORs dynamically to all the Actions. Currently RepositoriesCollection.Add methods adds the SOR to the current Action only and not other actions.


26. Changes made through SetTOProperty in one Action does not get propagated to Next Action.


27. Ability to enumerate all child objects present in the OR for a specified object.


28. Ability to specify nickname for Objects. This would help get a complete object hierarchy through just the nick name.


29. Ability to directly record objects into the SOR


Object Repository Manager Enhancements :

30. Ability to load and save directly to OR in XML format.

31. Ability for multiple users to access the Shared OR at the same time for updating.


32. Export/Import of Checkpoints from one SOR to another.


33. Merging of SOR’s to an existing SOR. Currently when two SOR are merged, the merged SOR needs to be saved as a different file.


34. Ability to update code when conflict resolution renames object during SOR merge. In case object A and B are merged and name A is chosen over B, all scripts using name B needs to be updated manually.

VbEdit Identification Properties In QTP

How to Identify Objects in QTP, & VBEdit Identification Properties In QTP
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 VbEdit 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.

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.

height

The object's height (in pixels).

HideSelection

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

Possible values:                                  
       True       False

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.

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)

MaxLength

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

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, such as Hebrew Windows95, 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, such as English Windows95, 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

width

The object's width (in pixels).

window id

The object's window identifier.

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


Retrieve the Value of a Property Using QTP

Retrieve the Current State of a Check Box :


Sub GetROProperty_Example()
'The following example uses the GetROProperty method to retrieve
'the state of a check box.

Val = Browser("Mercury Tours").Page("Find Flights").WebCheckBox("roundtrip").GetROProperty("Value")
' val contains the ON or OFF state of the check box

End Sub


Retrieve the Value of a Property in an Edit Box  :

Sub GetROProperty_Example()

'The following example iterates through the WebEdit objects
'on a page, searching for a specific WebEdit object in order
'to set a value for it.

Dim EditToSearch, ValueToSet, NumberOfEdits

'This is the value of the 'name' property for the WebEdit we want to find.
EditToSearch = "credit_card_number"

ValueToSet = "6543210123456789"
'Create a description object to help retrieve all WebEdit objects in a specific page.
Set oDesc = Description.Create()
oDesc("micclass").Value = "WebEdit"
'Retrieve all WebEdit objects in this page
Set EditCollection = Browser("Book a Flight: Mercury").Page("Book a Flight: Mercury").ChildObjects(oDesc)

NumberOfEdits = EditCollection.Count
'Search for a specific WebEdit and set its value
For i = 0 To NumberOfEdits - 1
    If EditCollection(i).GetROProperty("name") = EditToSearch Then
        EditCollection(i).Set ValueToSet
    End If
Next
End Sub


Retrieve the Value of a Property in an Edit Box :
  
Sub GetROProperty_Example()
'The following example uses the GetROProperty method to retrieve
'the number of items in a WebRadioGroup.

NumOfItems = Browser("Mercury Tours").Page("Find Flights").WebRadioGroup("seat pref").GetROProperty("Items Count")
' NumOfItems contains "3"

End Sub

GetRoProperty In QTP Description

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.


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

all items

The list of all items in the control (separated by a new line character).

AllowColumnReorder

Indicates whether the user can reorder columns using the mouse.

Possible values:                                  
       True       False (Default)

appearance

Indicates whether an object is painted at run-time with 3-D effects.

Possible values:

0: Paints controls and forms without visual effects.
1: (Default) Paints controls with three-dimensional effects.

arrange

Indicates how the icons in the ListView control's Icon or SmallIcon view are arranged.

Possible values:

0 (lvwNone): Items are randomly arranged.
1 (lvwAutoLeft): Items are aligned automatically along the left side of the control.
2 (lvwAutoTop): Items are aligned automatically along the top of the control.

attached text

The static text that is attached to a control.

checkboxes

Indicates whether the control has check boxes.

Possible values:                                  
       True       False (Default)

checked

The list of indexes of the object's checked items, if applicable.

Class Name

The object's class.

enabled

Indicates whether the object is enabled.

Possible values:                                  
       True       False

focused

Indicates whether the object has the focus.

Possible values:                                  
       True       False

ForeColor

The color of the object's text.

FullRowSelect

Indicates whether the entire row is selected.

Possible values:                                  
       True       False (Default)

GridLines

Indicates whether gridlines are displayed.

Possible values:                                  
       True       False (Default)

HasHScroll

Indicates whether the object has a horizontal scroll bar.

HasVScroll

Indicates whether the object has a vertical scroll bar.

HideColumnHeaders

Indicates whether column headers are hidden.

Possible values:                                  
       True       False (Default)

HotTracking

Indicates whether mouse-sensitive highlighting is enabled.

Possible values:                                  
       True       False (Default)

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.

items count

The number of items contained in the object.

LabelEdit

Indicates how the user edits the object's labels.

Possible values:

0 (lvwAutomatic): Automatic. The BeforeLabelEdit event is generated when the user clicks the label of a selected node.

1 (lvwManual): Manual. The BeforeLabelEdit event is generated only when the StartLabelEdit method is invoked.

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.

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.

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.

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.

MultiSelect

Indicates whether the user can select multiple objects or items.

Possible values:                                  
       True       False (Default)

name

The object's name.

NativeClass

The object's window class name.

RegExpWndClass

The permanent part of the MFC window class.

RegExpWndTitle

The constant part of the window title.

RightAligned

Indicates whether the object has generic "right-aligned" properties.

RightToLeftLayout

Indicates whether the object's horizontal origin is on the right edge.

RightToLeftReading

Indicates whether the object's text is displayed using right-to-left reading-order properties.

selection

The list of items that are selected in the control (separated by ;).

sorted

Indicates whether items in a collection are sorted.

Possible values:

True: Items are sorted according to the SortOrder property.
False

SortKey

Indicates how the objects in a ListView control are sorted.

Possible values:

0: Sorted using the object's Text property.
1 to n: Sorted using the specified sub-item collection index.

SortOrder

Indicates whether objects in a ListView control are sorted in ascending or descending order.

Possible values:

0 (lvwAscending): Ascending order.
1 (lvwDescending): Descending order.

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.

ToolTipText

The text displayed when the mouse pauses over the control.

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.

view

The appearance of the objects in the ListView.

Possible values:

0 (lvwIcon):

Icon. Each ListItem object is represented by a full-sized (standard) icon and a text label.

1 (lvwSmallIcon):

SmallIcon. Each ListItem object is represented by a small icon and a text label that appears to the right of the icon. The items appear horizontally.

2 (lvwList):

List. Each ListItem object is represented by a small icon and a text label that appears to the right of the icon. The ListItem objects are arranged vertically, each on its own line with information arranged in columns.

3 (lvwReport):

Report. Each ListItem object is displayed with its small icon and text labels. Additional information about each ListItem object may be provided in a subitem. The icons, text labels, and information appear in columns with the leftmost column containing the small icon, followed by the text label. Additional columns display the text for each of the item's subitems.

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