Object identification
Use mechanisms built in to TruClient scripts to improve object identification.
Object identification overview
Object identification is one of the biggest challenges with recording and replaying web applications, because objects can move or change content. The result is that when recorded objects change dynamically during replay, TruClient can lose the ability to automatically locate the object.
Various mechanisms are provided to overcome this challenge.
Object selection mode
Some of the object actions, for example, replacing an object, require you to select an object in the application. Various actions may be required in the application to make the object visible, such as mouse over and mouse click.
Working in object selection mode:
-
You can temporarily suspend object selection mode, and then re-enable it, by pressing CTRL+ALT+F6 . This enables you to navigate to a different part of the application before you make your selection.
-
To exit object selection mode without making a selection, press Esc.
Highlight an object
Use Highlight an object , located in the Object section of the step, to check if an object is visible in the browser window at that time. If found, the object is highlighted in the browser with a red outline.
If the object is not found, this may be an issue of pacing and timing. If the object cannot be found, an error message is displayed.
Use alternative steps
Alternative steps allow you to view instances in which there are multiple ways to perform the same user action in a step.
For example, you may be clicking on an option in a dropdown list in which the text changes based on some value. If you try to click based on the text, the step may fail. If you use an alternative step that selects the item in the list based on the ordinal value of the option within the list, the click succeeds regardless of the text.
Steps that have alternative options include the Alternative steps button . In the Alternative steps dialog box, select an option and click OK.
Note:
-
Before selecting one of the alternatives, try highlighting the object used by the alternative step and replaying it. This way you can make sure the alternative step is replaying the necessary action.
-
Alternative steps are created by default when there are multiple ways to perform the same action in a step. To disable this option, clear the Create alternative steps when applicable setting in the General settings Interactive options tab. For details, see Configure general settings.
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. |
XPath |
TruClient generates two possible XPaths, one based upon the object's property and the other based upon the object's DOM structure. Click the dropdown arrow next to the XPath edit box to select one of the XPaths for the object. You can manually modify the suggested path for the argument directly in the edit box, or in the dedicated Object identification - XPath editor. To revert to one of the original expressions, select one of the options from the dropdown again. The XPath function returns an array of the objects defined in the argument. Using XPath identification may help if, for example, you want to return a different list of objects, or if 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, we recommend you do not manually modify it. Instead, click Replace the test object to generate a new XPath expression. |
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. |
JavaScript |
JavaScript code that returns an object. For example: Using the JavaScript identification method, you can write JavaScript code that references the returned document. For example, the page returned by the server contains multiple links with the same "title" attribute (search results), and you want the script to randomly click on one of the available links. Object identification for this case, using the JavaScript identification method, may look something like this:
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. |
Descriptors |
Enables you to identify an object by its properties in the dedicated Object identification - Descriptors editor. For details, see Descriptors for scripts. |
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:
-
Click the Replace the test object button for a step. The Select object dialog box opens.
-
TruClient is now in object selection mode.
As you move the cursor in the browser window, potential object areas are highlighted with a green 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.
Tip: For details, see Object selection mode.
-
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.
-
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.
Non-standard upload of files
If the AUT implementation for file upload is not done in the standard way, the input element (which is dynamically created by inline script or script tag) is not supported for uploading a file. Instead, you can manually add a non-standard upload step to your script.
Note: The input element which is created in the DOM script tag is not attached to the DOM object.
To manually add a non-standard upload step to your script:
-
Open the Steps box to the Functions tab, and drag the Generic object action step to the relevant location in your script.
-
In the application browser window, select the object to upload.
-
Expand the step, and change the step Action to Upload.
-
Add the Path and set the required step parameters.
See also: