Share this page

# Descriptors for scripts

This topic describes how to use the Descriptors editor to identify objects in your TruClient 2.0 - Web scripts.

In this topic:

## About descriptors

Descriptors support object identification by specifying logical conditions for identifying the object. These include using the object's HTML and CSS properties (such as ID, Class, Position). Each condition contains a property, an operator, a value, and when applicable, optional arguments.

The descriptor conditions are created during recording, or when you select an object in the Step editor.

You use the Descriptors editor to improve or control identification, by adding or editing conditions. For example, you can edit descriptors to:

- Select a different menu item on each iteration, by parameterizing the menu text.
- Identify one of several similar objects by its ordinal position on the page. You can also choose a different object each iteration, by parameterizing the ordinal position.
- Add a condition that uses a property that TruClient does not record.
- Delete properties that are not required, and may change in a way irrelevant to identification.

Back to top

## Manually configure descriptors

You can configure descriptors in an existing step in your script, or add a Generic object action step.

To configure descriptors:

1. Click the More link in the step to open the Step editor.
2. In the Object section, select Descriptors as the ID method.
3. From the Descriptors box, open the Object identification - Descriptors editor.

4. Set the value for the tagName condition.

5. Edit the existing conditions as required.

6. To add additional conditions, click New condition and define the condition parameters:

   1. Select an object property. For details, see Object properties.

   2. Select an operator. For details, see Operators.

   3. Set the property value. The property value can be parameterized. For details, see Use parameters in scripts.

7. If relevant, specify the Object ordinal.

   When an element cannot be identified uniquely, you can use the Object ordinal to specify which occurrence to pick.

   Note: The Object ordinal is 1-based.

   For example, you would like to identify the third row of the column in the table below. You cannot do it without setting the Object ordinal to 3, since all the columns are the same.

       <table>
           <tr><td class”emptyrow”></td></tr>
           <tr><td class”emptyrow”></td></tr>
           <tr><td class”emptyrow”></td></tr>
           <tr><td class”emptyrow”></td></tr>
       </table>

   You can also set the field to randomized, to randomly select from a set of similar objects.

8. Click OK.
9. Click the highlight object button to verify that the object can be identified.

Back to top

## Custom properties and attributes

You can define a custom property or attribute for a descriptor condition. These use DOM attributes or JavaScript properties to identify the object. JavaScript properties are attached to the DOM object by JavaScript, or by the browser code during initialization.

Differences between custom properties and custom attributes

- The APIs to manipulate properties contain the dot operator.

  The attribute APIs use the getAttribute and setAttribute methods.

- JavaScript properties cannot be set by the HTML markup.
- JavaScript properties cannot be seen in the outerHTML/innerHTML strings of an element. However, attributes can be seen in the strings.
- The JSON.stringify function serializes a subset of JavaScript properties, but not DOM attributes.

Back to top

## Object properties

The following table provides a list of object properties used in TruClient:

Property category | Property | Value type | Description
--- | --- | --- | ---
Role | role | String | Standard role DOM attribute
Name | name | String | Standard name DOM attribute
Text | text | String | Inner text
Label | label | String | Element label
ARIA label | labelledby | White space separated string | Element IDs used as labels for the object
Title | title | White space separated string | Standard title DOM attribute
Input type | input/type | String | Type attribute of an input element
Input text | input/text/value | String | Text value of a text box
Button value | input/button/value | String | Caption for a button
Alternative text | alt | String | Alternative text when the text property is not available
Shadow host | isShadowHost | Boolean | DOM element to host a web component (rendered as a shadow-root element)
ID | id | String | Standard id DOM attribute
Class | class | Comma-separated string | List of the class stylesheet selectors
Image source | img/src | String | Standard src attribute of an image element
Hyperlink | url protocol host pathname search | String | Standard hyperlink properties
Form action | form/action | String | Standard form action
Form method | form/method | String | Standard form method DOM attribute
Table columns | tr/cols | Number | Number of columns for table row elements
Number | isNumber | Boolean | Determine if the text content is a number
Currency | isCurrency | Boolean | Determine if the text content is a currency value
Date | isDate | Boolean | Determine if the text content is a date value
Time | isTime | Boolean | Determine if the text content is a time value
DOM leaf | isLeaf | Boolean | Determine if the element is a tree leaf
Custom attribute | <User defined name> | String | Custom DOM attribute For details, see Custom properties and attributes
Custom property | <User defined name> | Expected value is a string, while the actual value can be any JavaScript type | Custom JavaScript property For details, see Custom properties and attributes

Back to top

## Operators

The following table provides a list of operators used in TruClient:

Operator | Description
--- | ---
equals | Compares the object property to the value specified in the Descriptors editor. For example, for class, the class has all the stylesheet selectors in the value, and no others.
equalsIgnoreDigits | Compares the object property to the value specified in the Descriptors editor, ignoring any numeric characters.
equalsIgnoreCase | Compares the object property to the value specified in the Descriptors editor, ignoring case considerations.
startsWith | The object property begins with the value specified in the Descriptors editor.
endsWith | The object property ends with the value specified in the Descriptors editor.
isSubstring | The object property, for example alt, is a substring of the value specified in the value field. Example: If the object alt is "aaa" and the value specified in the descriptor editor is "aaab", the return value for the specific expression will be true.
equalsIgnoreChars | Compares the object property to the value specified in the Descriptors editor, ignoring any characters specified in the Arguments section.
isRegExpMatch | The object property matches the regular expression specified as the value in the Descriptors editor. The value is a JavaScript regular expression object.
equalsIgnoreDeviation | Slight deviations are ignored when comparing the object property to the value specified in the Descriptors editor. Applicable only for metrics such as length and width.
contains | The object property contains the full value specified in the Descriptors editor. For example, for class, the class has all the stylesheet selectors in the value, and may have others.
contained | The object property contains the value specified in the Descriptors editor. For example, for class, the class has at least one of the stylesheet selectors in the value, and may have others.

Back to top

See also:

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