Project Properties - Object Identification Options

Applies to TestComplete 15.47, last modified on January 20, 2023
Information in this topic applies to web applications.

The information in this topic applies both to cross-platform and classic web tests.

The Open Applications > Web Testing > Object Identification options configure how TestComplete chooses identifiers for web objects and handles dynamic identifiers.

Changing these options can break existing tests in the project. Do not change these options unless absolutely necessary.

Requirements
  • You must have an active license for the TestComplete Web module.

  • The Web Testing plugin must be enabled in TestComplete.

    This plugin is installed and enabled automatically when you install TestComplete. You may want to check the plugin status in the File > Install Extensions dialog.

To view or modify the options
  1. Select Tools > Current Project Properties from the TestComplete menu.

    – or –

    Double-click the project in the Project Explorer. In the project editor that opens, select the Properties tab.

    – or –

    From the context menu of the project in the Project Explorer, select Edit > Properties.

  2. In the tree on the left of the project properties editor, select Open Applications > Web Testing > Object Identification.

TestComplete Project Properties - Object Identification

Click the image to enlarge it.

Available properties
  • Identification attribute – Specifies the primary HTML attribute that TestComplete uses to identify web elements: id or name.

    In web tests that implement the default approach, this attribute will be used to set the ObjectIdentifier property of the tested web element and form its name. See About Object Browser Naming Notation.

    In cross-platform web tests, this attribute will be used to form the search expression that the FindElement method will use to locate the web element.

    If the selected primary attribute is not specified for a web element in your web application, or if TestComplete is configured to ignore it (see below), TestComplete will use the second one. If the second attribute is also missing or ignored, TestComplete will use the object’s index among its siblings as an identifier.

  • Dynamic identifiers – Web applications can use dynamically generated ids (for example, ext-gen-123) that can change from session to session. This option specifies a list of patterns for detecting and handling dynamic identifiers in web applications.

    Depending on the pattern type and configuration, TestComplete can:

    • Ignore the dynamic identifier.

    • Extract and use the dynamic identifier’s stable non-changing part or parts (not applicable to cross-platform tests).

    By default, the list includes several predefined patterns for popular web application frameworks, such as ASP.NET, jQuery UI, Ext JS, GWT, and others.

    The pattern list includes:

    • Description - An arbitrary description of the pattern.

      The check box to the left of the description indicates whether the pattern is enabled.

    • Pattern Type - The following types are available:

      • Wildcard - A simple pattern that specifies a string of characters with dynamic parts masked by the * and ? wildcards. An asterisk ( * ) matches any sequence of characters (including an empty string), a question mark ( ? ) - any single character.

        If the web element’s attribute specified by the Identification attribute property matches a wildcard pattern, TestComplete will ignore the attribute and will use another identifier.

      • Regular expressions (RegExp) - A complex pattern with optional items, alternations, repetitions, and other rules. For more information, see Regular Expressions Syntax.

        If the web element’s attribute specified by the Identification attribute property matches the regular expression, TestComplete considers the attribute dynamic.

        In cross-platform web tests, TestComplete will ignore such attributes. It will not use them in a search condition it uses by default during the recording and will exclude them from the list of available locators, for example, from the Object Browser or Object Spy.

        In web tests that implement the default approach, TestComplete can ignore such an attribute completely or, if the attribute includes non-changing parts (such as treepicker in treepicker-1038), you can configure TestComplete to use them as an identifier. Specify the non-changing parts as sub-expressions of the regular expression by enclosing them in the capturing parenthesis { }, and then specify the needed sub-expression in the Stable ID Template to construct the object identifier.

    • ID Pattern - A pattern for dynamic identifiers. Any identifier that matches the pattern is considered dynamic. Case-sensitive.

    • Stable ID Template - For regular expressions only. Specifies a sub-expression of the regular expression to which the dynamic identifier matches and which you want to use as a stable identifier. For example, $1, $2, and so on. In the regular expression, the sub-expressions must be enclosed in the capturing parentheses { }.

      For cross-platform tests, this property is ignored.

    TestComplete checks the identifiers against the patterns in the order the patterns are listed in the table. To change the pattern priority, use the Move Up and Move Down buttons.

    To configure TestComplete to ignore a pattern, clear the appropriate check box to the left of the pattern description.

To add a new group

Click Add group and enter the group name. The group will be appended at the end of the table.

Add custom patterns and pattern groups only at the end of the list.

To add a new pattern via wizard

TestComplete includes the Add Dynamic Identifier Pattern wizard that automatically generates a match pattern for any given identifier. To add a pattern using this wizard:

  1. Select the group to add the pattern to and click Add.

  2. Follow the steps in the wizard to specify the dynamic identifier and review the generated pattern.

The pattern will be appended at the end of the group. You can modify it if necessary by changing the pattern data in the table.

To define a pattern manually

If you already have a regular expression or wildcard pattern, you can enter it directly into the table:

  1. Select the group to add a pattern to and click Add Item. A new item will be appended at the end of the group.

  2. Specify the pattern, pattern type and description.

  3. Select the Enable check box to activate the pattern.

To modify a pattern
  1. Click on a value in the table twice (not double-click).

  2. Enter the new value and press Enter.

To check if a specific identifier matches one of the existing patterns
  1. Click Test. This will open the Test Dynamic Identifier Patterns wizard.

  2. In the wizard, enter the identifier you want to test or point to a web page element with this identifier.

    Note: The identifier used by TestComplete is either the HTML id or name attribute of web objects, according to the Identification attribute setting.

If the specified identifier matches any of the existing patterns, the wizard will show the pattern description and the stable identifier extracted from this identifier (if any).

To enable or disable a pattern

Select or unselect the check box to the left of the pattern description.

To delete a pattern or group

Select the pattern or group and click Remove.

Tip: Instead of deleting patterns, you can unselect them in the table. The pattern definition remains in the project, but TestComplete will not use it.

The default values for the web object identification options that will be used in new TestComplete projects can be specified in the Default Project Properties - Object Identification Options dialog.

See Also

Classic Web Testing
Handle Dynamic Identifiers
Default Project Properties - General Web Testing Options
Project Properties

Highlight search results