TechChase
Skip to content


QTP Object Identification: Create and Map User Defined Object

While automating any application, we encounter challenge of recognizing application controls (Buttons, WinList, Calendar etc.) that cannot be identified in QTP , and is learned as generic WinObject. To help QuicKTest in uniquely identifying test control, we have to teach QuickTest (QTP) to identify as they belonged to a standard windows control object class. We need to define or map unidentified or user defined /custom class to a standard control (window or web) class. Mapped unidentified/ user defined/ or custom object to standard object, will add qtp custom controls or user defined control to standard test object classes list.

Configuring Object Identification

For configuring object identification we can do it in different ways.

  1. By setting through Object Mapping (Tools> Object Identification >(Environment) Standard Windows > User-Defined (button).
  2. Defining and Mapping Object Programmatically.

In this Article we will cover programmatically create object mapping for qtp custom controls or user-defined control. We use all standard TestObjectIndentification objects methods and properties with newly created user-defined TestObjectIndentification object.

Following are the steps to create user-defined object for custom object class, which is mapped to standard object class (WinList, Winbutton, WebControl etc.). After mapping the object to standard object class, we will do the settings for mandatory, assistive, and smart identification properties.

  1. Create QuickTest Application and WindowsAppsOptions object.
  2. User-Object creation using “CreateUserDefinedObject†method.
  3. Setting Ordinal Identifier property (location)
  4. Clear the Mandatory Properties, and create mandatory property list
  5. Initializing and Setting Assistive Properties
  6. Disable smart identification
  7. At end of test we will release user-defined object.

In this example we create a user-defined object of “CustomWinEditor” and which is mapped to a WinEditor test object. After mapping qtp custom controls or user defined control, we set the mandatory, assistive, and smart identification properties, as they would for any regular test object class.

Dim qtApp

 Dim qtOptions

 Dim UserDefWinEditor

 ' First Create the Application object and Launch in visible mode

 Set qtpApp = CreateObject("QuickTest.Application")

 qtpApp.Launch

 qtpApp.Visible = True

 ' Now we Create a user-defined object for "WindEditor" object and

 ' Setting the "selector type" for the our user-defined object

 ' and Clearing the MandatoryProperties list.

 Set UserDefWinEditor = qtpApp.Options.ObjectIdentification("WinEditor").CreateUserDefinedObject("CustomWinEditor")

 UserDefWinEditor.OrdinalIdentifier = "location"

 UserDefWinEditor.MandatoryProperties.RemoveAll

 ' Create a new Mandatory Properties list

 UserDefWinEditor.MandatoryProperties.Add ("attached text")

 UserDefWinEditor.MandatoryProperties.Add ("nativeclass")

 ' Now First Clear the AssistiveProperties list using AssistiveProperties.RemoveAll. and  ' Create a new AssistiveProperties for

 UserDefWinEditor.AssistiveProperties.RemoveAll

 UserDefWinEditor.AssistiveProperties.Add ("window id")

 UserDefWinEditor.AssistiveProperties.Add ("hWnd")

 ' Clear the smart identification settings.

 UserDefWinEditor.EnableSmartIdentification = False

 UserDefWinEditor.BaseFilterProperties.RemoveAll

 UserDefWinEditor.OptionalFilterProperties.RemoveAll

 ' Release the user-defined object Mapped to WinEditor Class.

 Set UserDefWinEditor = Nothing
Digg This
Reddit This
Buzz This
Vote on DZone
Share on a Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

Posted in Custom Controls, Quick Test Professional.

Tagged with , , .

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.


One Response

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Hanuman Prasad says

    Nice post. It helped me.
    Thanks.



Some HTML is OK

or, reply to this post via trackback.