Object Mapping
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.
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.
By setting through Object Mapping (Tools> Object Identification >(Environment) Standard Windows > User-Defined (button).
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.
Create QuickTest Application and WindowsAppsOptions object.
User-Object creation using “CreateUserDefinedObject” method.
Setting Ordinal Identifier property (location)
Clear the Mandatory Properties, and create mandatory property list
Initializing and Setting Assistive Properties
Disable smart identification
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
No comments:
Post a Comment