Use the .NET Windows Forms Spy

Spy on an object

  1. Make sure that the application on which you want to spy is specified in the Windows Applications Tab (Record and Run Settings Dialog Box), and that the application is running with Full Trust.

  2. Open the .NET Windows Forms application to the window containing the object on which you want to spy.

  3. Select Tools > .NET Windows Forms Spy. The .NET Windows Forms Spy Dialog Box opens.

  4. In the UFT .NET Windows Forms Spy window, click the pointing hand . Both UFT and the .NET Windows Forms Spy are minimized so that you can point to, and click on, any object in the open application.

  5. Click the object whose properties you want to view. If the location you clicked in your application is associated with more than one object, the Object Selection dialog box opens. The objects associated with the location you clicked are displayed in hierarchical order.

  6. Select the .NET Windows Forms object on which you want to spy and click OK. The UFT .NET Windows Forms Spy window opens showing the properties and values for the selected object.

  7. You can repeat these steps to spy on additional objects and add them to the Objects pane in the UFT .NET Windows Forms Spy window.

Back to top

Remove objects from the Objects pane

  1. Select the object that you want to remove.

  2. Perform one of the following:

    • Right-click the object and select Remove Object.
    • Press DELETE.

Back to top

View values of run-time object properties

In the Objects pane, select the object whose run-time object properties you want to view. The properties for the selected object are displayed in the Properties tab, with the property names on the left, and the property values on the right. A description of the selected property is displayed below the properties grid.

Note: Any changes you make to the values of run-time object properties in the .NET application remain in effect only for the current instance of the .NET application. The next time you run the .NET application, the properties will return to their original run-time values.

Back to top

View properties of embedded objects

  1. In the Properties tab, select the property whose embedded object properties you want to view.

  2. Click the Add selected property to the Objects tree button . The property is added to the Objects pane, and its run-time object properties and property values (if any) are shown in the Properties tab. Each time you add an embedded object to the Objects pane, it is added below its parent object, in a hierarchical format.

    Note: The Add selected property to the Objects tree button is disabled if the property's value is null, or the property is an object with no properties of its own.

Back to top

Locate a property by its value

  1. Click the Search a property by value button . The Find Property by Value dialog box opens.

  2. In the Find what box, specify the value for which you want to search.

  3. To find only those occurrences in which the capitalization matches the text you entered, select Match case.

  4. Specify the direction from the current cursor location in which you want to search: Up or Down.

  5. Click Find Next. The .NET Windows Forms Spy locates the property whose value you specified.

Back to top

Sort the properties grid

Click one of the following buttons to sort the properties grid in the Properties tab:

  • Categorized. Lists all properties and property values for the selected object, by category. Categories are listed alphabetically. You can collapse a category to reduce the number of visible properties. When you expand or collapse a category, a plus (+) or minus (-) is displayed to the left of the category name.

  • Alphabetical. Alphabetically sorts all run-time object properties for the selected object.

  • Note: The Property Pages button is not currently supported.

Back to top

Modify values of run-time object properties

  1. In the Properties tab, click the property value you want to modify. Properties shown in gray are defined as read-only in the .NET application and cannot be modified.

  2. Edit the property value as required. The property value displays different types of edit fields, depending on the needs of a particular property. These edit fields include edit boxes, drop-down lists, and links to custom editor dialog boxes.

    After you modify a property value, the new value is applied to the run-time instance of the .NET application. For example, you can change the text of an edit box label, change the background color of a dialog box from gray to red, and so on.

Back to top

View event arguments on an object

  1. In the Objects pane, select the object whose event arguments you want to view.

  2. Select the event in the Fired Events list whose arguments you want to view. The selected events arguments and argument values are shown directly below the event, in the Event Arguments list.

Back to top

Listen to specified events of an object

  1. In the Objects pane, select the object to whose events you want to listen.

  2. In the Events list, select the check boxes for the event types to which you want to listen.

    Note: The events that you select affect only the events that are listened to and logged by UFT. If you select or clear a check box for an event type after listening to events for an object, the events in the Fired Events list are not changed.

    Tip: You can click the Select All Events or Clear All Events buttons to select or clear all the event check boxes. You can also right-click the Events list and select Select All or Clear All.

  3. Click the Listen to Selected Events button . UFT starts listening to the specified events on the selected object, and Listening is displayed in the status bar.

  4. In your .NET application, perform the operations on the object to whose events you want to listen. The specified events are logged as they occur and are shown in the Fired Events list.

  5. When you want to stop listening to events, click the Stop Listening to Events button . UFT stops listening to and logging the specified events.

Back to top

Fire selected events on an object

  1. In the Objects pane, select the object whose events you want to fire.

  2. In the Fired Events list, select one or more events that you want to fire on your .NET application. You can select multiple events using standard Windows selection techniques (CTRL and SHIFT keys).

    Tip: The selected events are fired in the order in which they appear in the Fired Events list. If the events do not appear in the Fired Events list in the order in which you want to fire them, listen to more events on the object until the events you want are added to the Fired Events list in the required order.

  3. If the events you selected have editable arguments, you can change their argument values in the Event Arguments list if needed before firing the events. When the events are fired, they will be fired with the modified argument values.

  4. Click the Fire Selected Events button . The selected events are fired in the order in which they appear in the Fired Events list. You can view the effect that firing these events has on the relevant object in your .NET application. The status bar displays that the event firing is in progress, and when it ends.

Back to top

Remove specific events from the Fired Events list

  1. In the Objects pane, select the object whose events you want to remove from the Fired Events list.

  2. Select the events in the Fired Events list that you want to remove. You can select multiple events using standard Windows selection techniques (CTRL and SHIFT keys).

  3. Click the Clear Selected Events button . The selected events are removed from the Fired Events list.

Back to top

Clear all events from the Fired Events list

  1. In the Objects pane, select the object whose events you want to remove from the Fired Events list.

  2. Click the Clear Event List button . All the logged events are removed from the Fired Events list.

Back to top