Set Recognition Properties for Web Screen Elements

Automation Studio automatically chooses which recognition properties to use and sets their values appropriately when you capture a screen element from either Internet Explorer or any other supported browser.

However, to ensure that the screen element will be recognized reliably during run-time, you may need to modify the default recognition property settings. In some cases, it is possible to identify the need to modify the default settings immediately after the capture. In other cases, only after some testing will you realize that the default settings need to be modified for reliable recognition.

Preferred Recognition Properties

Automation Studio provides a list of recognition properties you can select. However, some recognition properties are more reliable than others.

The recommended recognition properties to use are listed below in descending order of preference:

  1. ID

  2. Selectors

  3. XPath

Set the ID Recognition Property

The ID recognition property is the most preferred method of recognition.

Because web developers use IDs to name elements on the pages they build:

  • The ID of an element is likely to be unique on the page.

  • The ID of an element is unlikely to change over time.

  • The ID of an element remains unchanged even if the web developer moves the element to a different position on the page or makes other changes to the structure of the page.

Unfortunately, web developers do not assign IDs to all elements, so this option is not always available.

Set the Selector Recognition Property

If the ID recognition property cannot be used, you should try to use the selector recognition property instead.

What is a Selector?

The selector recognition property identifies the screen element by its location in the structure of the web page. If Automation Studio is unable to use the ID property, it will usually use the Selector property instead.

For example, if you try to capture the NICE logo at www.nice.com, the Selector property will be used.

The default selector is shown below:

html > body:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(2) > nav:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(1)

The selector specifies the path from the html tag at the top of the page, through the body tag, and past multiple div tags, to the captured element.

The selector recognition property is specified using CSS selectors.

A useful reference for CSS selectors is provided at https://www.w3schools.com.

Recommendations for Selectors

Tips for choosing effective selectors are listed below. Some examples of specifying selectors are provided.

  • Shorten the selector

    As explained above, the default selector Automation Studio specifies maps the screen element from the top of the page. This results in a very long selector. If the web page developer makes any modification to the structure of the page along that path, recognition of the captured screen element may fail.

    Best practice is to use selectors that are no longer than 3 elements long to reduce susceptibility to web page structure changes.

  • Generalize the selector

    If the selector includes any data that is unlikely to remain constant, the selector should be modified to exclude that data.

    In the example below, the selector includes what looks like a computer-generated code which may change over time.

Specifying Selectors

The examples below demonstrate how to build and test selectors.

All supported web browsers provide developer tools that are very useful when choosing selectors. For more information about using developer tools, see here.

A useful reference for CSS selectors is provided at https://www.w3schools.com.