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

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.

Smart Identification In QTP

Configuring Smart Identification


When the learned definition for an object does not enable QuickTest Pro/ QTP to identify an object, QuickTest uses the Smart Identification definition (if defined and enabled) to identify the object.

The Smart Identification dialog box enables you to create and modify the Smart Identification definition that QuickTest uses for a selected test object class. 


About Configuring Smart Identification 

When QuickTest uses the learned description to identify an object, it searches for an object that matches all of the property values in the description. In most cases, this description is the simplest way to identify the object, and, unless the main properties of the object change, this method will work.

If QuickTest is unable to find any object that matches the learned object description, or if it finds more than one object that fits the description, then QuickTest ignores the learned description, and uses the Smart Identification mechanism to try to identify the object.

While the Smart Identification mechanism is more complex, it is more flexible. Therefore, if configured logically, a Smart Identification definition can probably help QuickTest identify an object, if it is present, even when the learned description fails.

The Smart Identification mechanism uses two types of properties:


  • Base Filter Properties. The most fundamental properties of a particular test object class; those whose values cannot be changed without changing the essence of the original object. For example, if a Web link's tag was changed from to any other value, you could no longer call it the same object.


  • Optional Filter Properties. Other properties that can help identify objects of a particular class. These properties are unlikely to change on a regular basis, but can be ignored if they are no longer applicable.
Understanding Smart Identification :

If QuickTest activates the Smart Identification mechanism during a run session (because it was unable to identify an object based on its learned description), it follows the following process to identify the object:


  1. QuickTest "forgets" the learned test object description and creates a new object candidate list containing the objects (within the object's parent object) that match all of the properties defined in the Base Filter Properties list.


  2. QuickTest filters out any object in the object candidate list that does not match the first property listed in the Optional Filter Properties list. The remaining objects become the new object candidate list.


  3. QuickTest evaluates the new object candidate list:


    • If the new object candidate list still has more than one object, QuickTest uses the new (smaller) object candidate list to repeat step 2 for the next optional filter property in the list.


    • If the new object candidate list is empty, QuickTest ignores this optional filter property, returns to the previous object candidate list, and repeats step 2 for the next optional filter property in the list.


    • If the object candidate list contains exactly one object, then QuickTest concludes that it has identified the object and performs the statement containing the object.


  4. QuickTest continues the process described in steps 2 and 3 until it either identifies one object, or runs out of optional filter properties to use.
  5. If, after completing the Smart Identification elimination process, QuickTest still cannot identify the object, then QuickTest uses the learned description plus the ordinal identifier to identify the object.
    If the combined learned description and ordinal identifier are not sufficient to identify the object, then QuickTest stops the run session and displays a Run Error message. 
Reviewing Smart Identification Information in the Test Results :

If the learned description does not enable QuickTest to identify a specified object in a step, and a Smart Identification definition is defined (and enabled) for the object, then QuickTest tries to identify the object using the Smart Identification mechanism.

If QuickTest successfully uses Smart Identification to find an object after no object matches the learned description, the step is assigned a Warning status in the Test Results, and the result details for the step indicate that the Smart Identification mechanism was used.

If the Smart Identification mechanism cannot successfully identify the object, QuickTest uses the learned description plus the ordinal identifier to identify the object. If the object is still not identified, the component fails and a normal failed step is displayed in the results.

The explanation below describes the process that QuickTest uses to find the Login object using Smart Identification:


  1. According to the Smart Identification definition for Web image objects, QuickTest learned the values of the following properties it learned the Login image:

      The learned values are as follows:
      Base Filter Properties:

      Property

      Value

      html tag

      INPUT
      Optional Filter Properties:

      Property

      Value

      alt

      Login

      image type

      Image Button

      name

      login

      file name

      login.gif

      class


      visible

      1


    1. QuickTest begins the Smart Identification process by identifying the five objects on the Mercury Tours page that match the base filter properties definition (html tag = INPUT). QuickTest considers these to be the object candidates and begins checking the object candidates against the Optional Filter Properties list.


    2. QuickTest checks the alt property of each of the object candidates, but none have the alt value: Login, so QuickTest ignores this property and moves on to the next one.


    3. QuickTest checks the image type property of the each of the object candidates, but none have the image type value: Image Button, so QuickTest ignores this property and moves on to the next one.


    4. QuickTest checks the name property of each of the object candidates, and finds that two of the objects (both the basic and VIP Login buttons) have the name: login. QuickTest filters out the other three objects from the list, and these two login buttons become the new object candidates.


    5. QuickTest checks the file name property of the two remaining object candidates. Only one of them has the file name login.gif, so QuickTest correctly concludes that it has found the Login button and clicks it.

You use the Smart Identification Properties dialog box, accessible from the Object Identification dialog box, to configure the Smart Identification definition for a test object class.

To configure Smart Identification properties:


  1. Select Tools > Object Identification. The Object Identification dialog box opens.
  2. Select the appropriate environment in the Environment list. The test object classes associated with the selected environment are displayed in the Test Object classes list.
  3. Select the test object class you want to configure.


  4. Click the Configure button next to the Enable Smart Identification check box. The Configure button is enabled only when the Enable Smart Identification option is selected. The Smart Identification Properties dialog box opens.
  5.  
  6. In the Base Filter Properties list, click Add/Remove. The Add/Remove Properties dialog box for base filter properties opens.
  7. Select the properties you want to include in the Base Filter Properties list and/or clear the properties you want to remove from the list.
Note: You cannot include the same property in both the base and optional property lists.

You can specify a new property by clicking New and specifying a valid property name in the displayed dialog box.

Tip: You can also add property names to the set of available properties for Web objects using the attribute/ notation. To do this, click New. The New Property dialog box opens. Enter a valid property in the format attribute/ and click OK. The new property is added to the Base Filter Properties list. For example, to add a property called MyColor, enter attribute/MyColor.



  • Click OK to close the Add/Remove Properties dialog box. The updated set of base filter properties is displayed in the Base Filter Properties list.



  • In the Optional Filter Properties list, click Add/Remove. The Add/Remove Properties dialog box for optional filter properties opens.

  • Select the properties you want to include in the Optional Filter Properties list and/or clear the properties you want to remove from the list.


  • Note: You cannot include the same property in both the base and optional property lists.

    You can specify a new property by clicking New and specifying a valid property name in the displayed dialog box.

    Tip: You can also add property names to the set of available properties for Web objects using the attribute/ notation. To do this, click New. The New Property dialog box opens. Enter a valid property in the format attribute/ and click OK. The new property is added to the Optional Filter Properties list. For example, to add a property called MyColor, enter attribute/MyColor.





  • Click OK to close the Add/Remove Properties dialog box. The properties are displayed in the Optional Filter Properties list.



    1. Use the up and down arrows  to set your preferred order for the optional filter properties. When QuickTest uses the Smart Identification mechanism, it checks the remaining object candidates against the optional properties one-by-one according to the order you set in the Optional Filter Properties list until it filters the object candidates down to one object.

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

    Accessing Native Properties and Operations In QTP

    Accessing Native Properties and Operations


    If the test object operations and identification properties available for a particular test object do not provide the functionality you need, you can access the native operations and properties of any run-time object in your application using the Object property.


    You can use the statement completion feature with object properties to view a list of the available native operations and properties of an object. For more information on the statement completion option, see Generating Statements in the Expert View or in a Function Library.


    Tip: If the object is a Web object, you can also reference its native properties in programmatic descriptions using the attribute/property notation. For more information, see Accessing User-Defined Properties of Web Objects.

    For more information, see:


    • Retrieving Native Properties


    • Activating Native Operations


    • Accessing User-Defined Properties of Web Objects

    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 

    Activating Native Operations

    You can use the Object property to activate the internal operations of any run-time object. For example, you can activate the native focus method of the edit box as follows:

    Dim MyWebEdit

    Set MyWebEdit=Browser("Mercury Tours").Page("Mercury Tours").WebEdit("username").Object

    MyWebEdit.focus


    Accessing User-Defined Properties of Web Objects

    You can use the attribute/ notation to access native properties of Web objects and use these properties to identify such objects with programmatic descriptions.

    For example, suppose a Web page has the same company logo image in two places on the page:

    IMG src="logo.gif" LogoID="122"

    IMG src="logo.gif" LogoID="123"

    You could identify the image that you want to click using a programmatic description by including the user-defined property LogoID in the description as follows:

    Browser("Mercury Tours").Page("Find Flights").Image("src:=logo.gif","attribute/LogoID:=123").Click 68, 12


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

    Understanding Test Object and Native Properties and Operations In QTP

    Understanding Test Object and Native Properties and Operations


    The identification property set for each test object is created and maintained by QuickTest. The native property set for each run-time object is created and maintained by the object creator (for example, Microsoft for Microsoft Internet Explorer objects, Netscape for Netscape Browser objects, the product developer for ActiveX objects, and so on).

    Similarly, a test object operation is a method or property that QuickTest recognizes as applicable to a particular test object class. For example, the Click method is applicable to a WebButton test object. As you add steps to your test, you specify which operation to perform on each test object. If you record steps, QuickTest records the relevant operation as it is performed on an object.

    During a run session, QuickTest performs the specified test object operation on the run-time object. Native operations are the methods of the object in your application as defined by the object creator.

    Property values of objects in your application may change dynamically each time your application opens, or based on certain conditions. You may need to modify the identification property values to match the native property values. You can modify identification properties manually while designing your test, or use SetTOProperty statements during a run session. You can also use regular expressions to identify property values based on conditions or patterns you define, or you can parameterize property values with Data Table parameters so that a different value is used during each iteration of the test. For more information on modifying object properties, see Managing Test Objects in Object Repositories. For more information on parameterization, see Parameterizing Values. For more information on regular expressions, see Understanding and Using Regular Expressions.

    You can view or modify the identification property values that are stored with your test in the Object Properties or Object Repository dialog box. For more information, see Specifying or Modifying Property Values.

    You can view the current identification property values of any object on your desktop using the Properties tab of the Object Spy. For more information, see Viewing Object Properties and Operations Using the Object Spy.

    You can view the syntax of the test object operations as well as the native operations of any object on your desktop using the Operations tab of the Object Spy. For more information, see Viewing Object Properties and Operations Using the Object Spy.

    You can retrieve or modify property values of the test object during the run session by adding GetTOProperty and SetTOProperty statements in the Keyword View or Expert View. You can retrieve property values from the run-time object during the run session by adding GetROProperty statements. For more information, see Retrieving and Setting Identification Property Values.

    If the available test object operations and identification properties for a test object do not provide the functionality you need, you can access the internal operations and properties of the run-time object using the Object property. You can also use the attribute object property to identify Web objects in your application according to user-defined properties. For information, see Accessing Native Properties and Operations.