UIA Pro Add-in Best practices

Relevant for: GUI tests and components

In UIA Pro, multiple methods can often achieve the same outcome. However, the availability and effectiveness of each method depends on the application you’re testing and the specific UI Automation patterns it supports. Selecting the appropriate method requires understanding the UI structure and the capabilities exposed by the target application.

This topic describes best practices and guidelines for using the UIA Pro Add-in to interact with the UI elements.

Guidelines and best practices

When using the UIA Pro Add-in, OpenText recommends the following guidelines:

  • Prefer UIA-Specific Methods

    For greater reliability and flexibility, especially when working with complex user interfaces, use pattern-based methods rather than device replay methods if possible.

    Note: Select methods based on the application you're testing and the patterns its objects support. Not all methods are always supported. Use the most appropriate method, preferring UIA-specific methods when available.

    Example 1: Button click

    We recommend using the UIA pattern based ‘Invoke’ method instead of the device replay ‘Click’ method , when possible.

    For example, prefer   UIAProButton("Button").Invoke instead of UIAProButton("Button").Click for the following reasons:

    UIA pattern method (Invoke)

    Device replay method (Click) 

    Uses UIA framework calls directly

    Simulates a physical mouse click

    Not dependent on UI responsiveness  Subject to UI responsiveness issues 
    Can work even when UI elements aren't directly visible  None
    More reliable if the pattern is supported  None

    Example 2: Retrieving a cell value from a table

    Depending on how the application you are testing implements UI Automation, use GetCellValue or GetCellText to retrieve a table cell's value. While some cells may appear visually similar, they expose data differently through ValuePattern, TextPattern, or both.

    ValuePattern method

    TextPattern method

    UIAProDataGrid("Grid").GridPattern.GetCellValue(0,0) UIAProDataGrid("Grid").GridPattern.GetCellText(0,0)
    Retrieves the value via ValuePattern.GetValue  Retrieves the text via TextPattern.GetText 
  • Validate pattern availability

    When a control supports multiple patterns, select the one that aligns most closely with the action you need to simulate, preferring UIA specific methods. To check supported patterns during runtime, use HasSupportedPattern or HasSupportedPatterns methods.

    Make sure your test can handle scenarios where patterns might not be available during runtime.

  • Start with high-level functions for common tasks and progress to low-level functions in complex scenarios.

    For details, see UIA Pro functions.

  • Verify an object’s functionality

    A control type’s visual appearance may resemble a standard UI element (e.g. Button or dropdown), but its behavior might be different. For example, a control that looks like a button might not support the InvokePattern. Instead, it could implement a different pattern such as TogglePattern or even custom behavior.

    Always inspect the control type’s supported patterns programmatically rather than relying on its appearance.

  • See also:

  • UIA Pro Add-in

  • UIA Pro Legacy or Enhanced Beta offering