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.

Back to top

## Modify the object identification method

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

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. Using the JavaScript identification method, you can 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 | If TruClient identification fails, you can try using the XPath identification method. This method identifies 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 | Enables you to identify an object by its properties in the dedicated Object identification - Descriptors editor. For details, see Descriptors for scripts.

Back to top

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

Back to top

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

Back to top

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

Back to top

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 25.1-25.3 All View Local Help Center View Online Help Center Version: