Share this page

# Object identification

Use mechanisms built into TruClient 2.0 to improve object identification.

In this topic:

## About object identification

Object identification is one of the biggest challenges with recording and replaying web applications, because objects can move or change content. When recorded objects change dynamically during replay, TruClient can lose the ability to automatically locate the object.

This page describes various mechanisms provided to overcome this challenge.

Working with objects:

- Selecting objects. You select an object in the application in object selection mode.

  However, various actions may be required in the application to make the object visible for selection. For example, you may need to hover over, or click on, an item; or to navigate to a different part of the application.

  You can temporarily suspend object selection mode, so that you can perform these actions before selecting the object.

  - To suspend selection mode, press CTRL+ALT+F6 . Re-enable the mode the same way.

  - To exit the mode without making a selection, press ESC.

- Highlighting objects. Use Highlight an object to check if an object is visible in the browser window at that time. If found, a rectangle identifies the object in the browser.

  If the object is not found, an error message is displayed. This may be due to issues with pacing or timing.

## Modify the object identification method

You can modify the object ID method in the Object section of the step properties. If TruClient identification fails, try using one of the alternative methods available in the dropdown list.

The following options are available:

ID method | Description
--- | ---
TruClient identification | The default object identification method, enabling TruClient to use its internal advanced algorithms to locate the object.
JavaScript | JavaScript code that returns an object. This method enables you to write JavaScript code that references the returned object. Use the dedicated Object identification - JavaScript editor to write your own JavaScript code. You can call CSS selectors and XPath expressions from JavaScript functions in your code. You can use the generated XPath or CSS expressions, or add your own. They are evaluated in evalXPath or evalCSS functions. For details, see Work with JavaScript.
Cascading style sheets (CSS) | TruClient generates a CSS selector to identify the object. You can manually modify the suggested selector for the argument directly in the edit box, or in the dedicated Object identification - CSS editor. To revert to the original expression, click the dropdown arrow next to the CSS edit box. If you switch to the JavaScript identification method, the CSS selector is entered as the argument in an evalCSS function in the JavaScript field. Note: The CSS method is recommended over the XPath method.
XPath | This method enables identification of the object based on an XPath expression that defines the object in the DOM tree. When applicable, click the dropdown arrow next to the XPath edit box to select a suggested XPath for the object. You can manually modify the suggested path. To revert to one of the original expressions generated by TruClient, select one of the options from the dropdown again. Using XPath identification may help if, for example, you need to select the first search result for the step, regardless of the term being searched for. Note: If the object to identify is encapsulated in a web component, and you want to change the XPath expression, it is not recommended to manually modify it. Instead, click Replace the test object to generate a new XPath expression.
Descriptors | This method enables you to identify an object by its properties in the dedicated Object identification - Descriptors editor. For details, see Descriptors for scripts.
Image | This method enables you to use visual template matching to identify the relevant object. To use image identification: Make sure the relevant page is displayed in the application browser window. Select Image as the ID method, then click the Capture object screenshot button . The Capture Object Screenshot box opens in the Development window, indicating that object capture is activated. Move the cursor to the highlighted areas in the application browser window. The cursor changes to a snipping tool. Use the tool to select the required object, then click Crop Selection to save your selection. The Capture Object Screenshot box closes, and the captured image is saved in the test-objects-screenshots folder in the script folder. Note: When using image identification, the browser may scroll through the page during replay, as it scans the page to find a visual match for the captured screenshot. When exporting libraries that contain test objects using image identification, copy the contents of the test-objects-screenshots folder into the new script folder.

## Use alternative steps

Alternative steps are created automatically when TruClient detects that there are multiples ways to perform the same user action for a step. Steps that have alternative options include the Alternative steps button:

Tip: To deactivate this functionality, clear the Create alternative steps when applicable setting in the General settings Interactive options tab. For details, see Configure general settings.

To use an alternative step:

1. Click the Alternative steps button in the step. The Alternative steps dialog box is opened.

2. Check the correct action is performed by the alternative step, before selecting it.

   Highlight the object used by the step, and replay the action.

3. Select an option and click OK.

Example: Your application includes a dropdown list in which the text changes, based on some value. If a step is set to click on specific text in the list, the step may fail.

Instead, you use an alternative step that selects an option based on the ordinal value of the option within the list. The click then succeeds, regardless of the actual text.

## Modify the script timing

Sometimes objects may not be found, even though the Highlight option finds the correct object, because of timing and synchronization issues. For example, the script may be looking for an object that was in the application, but the script replayed too quickly and already progressed to another page.

If you suspect that the object is not being found because of a timing or synchronization issue, you can insert Wait steps. For details, see Insert Wait steps.

## Replace an object

If you selected the wrong object during recording, or an object has permanently changed, you can replace it with a different object without replacing the step. This deletes manual changes you made to the original step.

To replace an object:

1. Click the Replace the test object button for a step. The Select object dialog box opens.

2. TruClient is now in object selection mode.

   As you move the cursor in the browser window, potential object areas are highlighted with a rectangle. The Select object dialog box displays the roles and name for each highlighted area, and informs you if it matches the step action or not.

3. Click in a highlighted area to select it as the new object. The object is replaced in the step, and the Select object dialog box is closed.

4. Replay the script to make sure that the object is recognized. TruClient removes any knowledge of the previous object, and learns the new object you selected.

## See also

- Debug scripts
- Step properties
- Replay scripts

https://admhelp.microfocus.com VuGen,Professional Performance Engineering,Performance Engineering for Developers 8942
Tips to improve your search results... OpenText™ Virtual User Generator Help Center OpenText™ VuGen Help 26.1-26.3 All View Local Help Center View Online Help Center Version: