Saturday, August 22, 2026

Mastering UFT Object Identification

Mastering Object Identification in UFT: Handling Custom Controls and Complex UI Patterns

Object identification stands as the cornerstone of successful automation testing with Unified Functional Testing (UFT). The ability to accurately and reliably locate objects in your application determines the stability and maintainability of your test scripts. This becomes particularly challenging when dealing with custom controls and complex UI patterns that deviate from standard web or desktop elements. In this comprehensive guide, we'll explore how UFT handles these challenging scenarios and provide practical techniques to overcome common obstacles in object identification.

Mastering Object Identification in UFT: Handling Custom Controls and Complex UI Patterns


Understanding UFT's Object Identification Framework

UFT's Object Identification Framework forms the backbone of its automation capabilities, serving as the mechanism through which the tool recognizes and interacts with application elements. At its core, this framework relies on a hierarchical model known as the Test Object Model (TOM), which maps application objects to corresponding test objects that UFT can understand and manipulate. When UFT encounters an application element, it first attempts to identify the object using a combination of properties defined in the Object Identification settings, including mandatory and assistive properties.

The object identification workflow follows a systematic sequence: UFT first tries to identify objects using their mandatory properties. If these aren't sufficient, it considers assistive properties, and finally resorts to ordinal identifiers if necessary. Each step in this process is designed to handle increasingly complex scenarios, making UFT adaptable to various application architectures. Understanding this workflow is essential for troubleshooting identification issues and optimizing test performance, especially when working with applications that feature custom controls or intricate UI patterns.

The identification process follows a systematic approach. UFT first checks if the object can be identified using the mandatory properties alone. If multiple objects share the same mandatory properties, UFT then employs assistive properties to distinguish between them. This layered approach ensures that objects can be identified consistently across different application states and environments. However, when dealing with standard web elements, this process often works seamlessly, as UFT has built-in support for common controls like buttons, text fields, and dropdown menus.

The Test Object Model in UFT consists of:

  • Test Objects: Objects as understood by UFT
  • Runtime Objects: Actual objects in the application
  • Properties: Attributes used to identify objects
  • Methods: Actions that can be performed on objects

When the default identification process fails to uniquely identify an object, UFT can employ additional mechanisms like ordinal identifiers or smart identification to locate the element. This multi-layered approach provides flexibility in handling various application scenarios while maintaining the reliability of test automation.

The Challenge of Custom Controls in UFT

Modern applications often incorporate custom controls that deviate from standard UI elements, presenting significant challenges for UFT's object identification capabilities. These custom controls, built using technologies like WPF, Silverlight, or proprietary frameworks, frequently lack the standard properties that UFT relies on for identification. As a result, testers must develop specialized approaches to ensure these elements can be consistently recognized and manipulated during test execution.

Custom controls present unique challenges for object identification in UFT because they often deviate from the standard objects in UFT's test object model. These controls, developed specifically for an application, may lack the properties that UFT typically uses for identification, leading to unreliable or failed object recognition. The primary difficulties include:

  • Non-standard property sets that don't align with UFT's default identification mechanisms
  • Dynamic properties that change between test runs
  • Complex hierarchies that make navigation difficult
  • Custom rendering that bypasses standard UI frameworks

When UFT encounters these custom controls, its default identification strategy often falls short. The tool might recognize the object as generic "WinObject" or "WebElement" rather than the specific control type, limiting your ability to perform meaningful operations. This limitation necessitates a more sophisticated approach to object identification, moving beyond default settings to implement custom identification strategies tailored to your application's unique architecture.

The primary difficulty with custom controls stems from their unique implementation. Unlike standard buttons or text fields, custom controls may not expose conventional properties such as "name" or "id" that UFT can use for identification. Instead, they might rely on internal properties, visual characteristics, or complex hierarchies that are not immediately apparent to UFT's default identification mechanisms. This discrepancy between how the control appears to users and how it's represented internally can lead to identification failures, causing tests to fail even when the application functions correctly.

To address these challenges, testers must first understand the underlying technology used to create the custom controls. This knowledge allows them to identify which properties are available for identification and which methods might be more effective. For instance, WPF applications often rely on Automation IDs or attached properties that can be leveraged for identification, while custom JavaScript components might require a different approach focusing on CSS selectors or XPath expressions.

' Example of identifying a custom control using descriptive programming
Set customButton = Description.Create()
customButton("micclass").Value = "CustomButton"
customButton("customProperty").Value = "uniqueValue"
customButton("index").Value = 0

' Perform action on the custom control
Browser("MyApplication").Page("MainPage").WebEdit(customButton).Click

When working with custom controls, it's essential to document the identification strategy thoroughly. This documentation should include the properties used, the rationale for selecting them, and any special handling required during test execution. Such documentation not only aids in maintaining existing tests but also provides guidance for team members who may need to work with the same custom controls in the future.

The Object Identification Center (OIC)

The Object Identification Center (OIC) serves as UFT's primary tool for creating unique and robust identifications for application objects, particularly custom controls. This powerful interface allows testers to view and modify the properties that UFT uses to identify objects, providing granular control over the identification process. Through the OIC, you can add, remove, or modify properties in both the Mandatory and Assistive property lists, tailoring the identification strategy to your specific application needs.

The OIC offers several valuable features for handling custom controls:

  • Visual representation of the object hierarchy
  • Property filtering and search capabilities
  • Comparison of property values across multiple instances
  • Ability to test identification strategies in real-time

Using the OIC effectively requires understanding which properties are most reliable for your custom controls. For instance, with a custom grid control, you might identify objects using a combination of grid coordinates, cell content, and custom attributes rather than relying solely on standard properties. The key is to identify properties that remain stable across different test runs while uniquely distinguishing the object from similar elements.

Regular maintenance of object identification settings in the OIC is crucial as applications evolve. What works today might fail after an application update, making periodic reviews of your identification strategies essential for maintaining test stability.

Smart Identification and Ordinal Identifiers

When default properties fail to uniquely identify an object, UFT can employ Smart Identification as a fallback mechanism. Smart Identification uses a set of "base filter" and "associated" properties to create a more flexible identification strategy. If the base filter properties don't yield a unique match, UFT attempts to identify the object using associated properties, providing a secondary method of recognition.

Ordinal identifiers represent another layer of defense in UFT's identification arsenal. These identifiers use an object's position relative to other objects as a distinguishing characteristic:

  • The index indicates an object's position relative to other objects of the same type
  • The location specifies an object's coordinates on the screen
  • The size defines an object's dimensions

For custom controls, these ordinal identifiers can be particularly valuable when other properties are unreliable. However, they come with the risk of breaking if the UI layout changes, making them best used as a last resort or in combination with other identification methods.

Implementing Smart Identification requires careful configuration to balance flexibility with precision. Too permissive settings might cause UFT to identify the wrong object, while too restrictive settings could lead to unnecessary identification failures. The key is to find the right combination of properties that provides sufficient uniqueness without being overly dependent on volatile characteristics.

' Example of enabling Smart Identification for a specific test object
Set MyObject = Description.Create()
MyObject("micclass").Value = "WinObject"
MyObject("nativeclass").Value = "CustomControl"
MyObject("smart Identification").Value = True

' Using ordinal identifiers as a fallback
MyObject("index").Value = 0  ' First object of this type

UFT's Approach to Complex UI Patterns

Complex UI patterns, such as dynamic content, nested frames, or responsive layouts, present additional hurdles for object identification in UFT. These patterns often involve elements that change their properties, positions, or visibility based on user interactions or application state, making them difficult to identify consistently. UFT addresses these challenges through several mechanisms designed to handle dynamic and complex UI structures.

One of UFT's key strategies for dealing with complex UI patterns is the use of descriptive programming. Unlike the default object identification method, which relies on stored properties, descriptive programming allows testers to define object properties at runtime. This approach provides greater flexibility when objects have unstable properties or when the structure of the application changes frequently. By specifying the exact properties needed to identify an object during test execution, testers can create more resilient tests that adapt to variations in the application.

Another important aspect of UFT's approach is its ability to handle nested objects and frames. Modern applications often embed content within multiple levels of frames or iframes, each with its own object hierarchy. UFT provides methods to navigate through these nested structures, allowing testers to interact with elements deep within the application's UI. This capability is particularly valuable when testing applications that use frameworks like Angular or React, which often create complex component hierarchies.

' Example of handling nested frames in UFT
Browser("MyApplication").Page("MainPage").Frame("outerFrame").Frame("innerFrame").WebButton("submitButton").Click

' Example of using descriptive programming for dynamic content
Set dynamicElement = Description.Create()
dynamicElement("micclass").Value = "WebEdit"
dynamicElement("name").Value = "dynamicField_" & Date()

Browser("MyApplication").Page("MainPage").WebEdit(dynamicElement).Set "test data"

UFT also offers specialized support for certain UI patterns through add-ins and integration with other technologies. For example, the .NET add-in provides enhanced support for WPF and WinForms applications, while the SAP add-in offers specialized handling for SAP GUI elements. These extensions expand UFT's capabilities, making it possible to automate even the most complex enterprise applications with custom controls and intricate UI patterns.

Advanced Techniques for Object Identification

When standard object identification methods fall short, testers can turn to advanced techniques to ensure their UFT scripts can reliably interact with application elements. These techniques go beyond the default identification process, offering more sophisticated approaches to handle challenging scenarios involving custom controls and complex UI patterns.

One such technique is the use of regular expressions in object identification. When objects have properties that follow a predictable pattern but vary in specific details, regular expressions can provide a flexible way to identify them. For example, if an application generates buttons with names like "btnSubmit_1", "btnSubmit_2", and so on, a regular expression pattern like "btnSubmit_[0-9]+" can match all such buttons regardless of their numeric suffix. This approach is particularly useful when dealing with dynamically generated elements that share common characteristics.

Another powerful technique is the utilization of the Object Spy in combination with programming. The Object Spy provides a detailed view of an object's properties and methods, which can be invaluable when developing custom identification strategies. By examining the properties of difficult-to-identify objects, testers can discover unique attributes that can be leveraged in their scripts. This discovery process often reveals properties that are not immediately apparent but provide stable and reliable identification.

Advanced identification techniques include:

  • Regular expressions for pattern matching
  • Visual-based identification for UI elements
  • Programming extensions for custom identification logic
  • Repository parameterization for dynamic values

For truly complex scenarios, consider implementing custom identification functions that encapsulate your organization's unique identification logic. These functions can combine multiple techniques, handle special cases, and provide consistent object identification across your test suite.

' Using descriptive programming for custom controls
Browser("MyApp").Page("Main").WebEdit("name:=username_.*").Set "testuser"

' Implementing regular expressions for dynamic object identification
Set Description = Description.Create()
Description("micclass").Value = "Link"
Description("innertext").Value = "Report.*[0-9]{4}"  ' Matches "Report 2023", "Report 2024", etc.
Set ReportLink = Desktop.Object(Description)
ReportLink.Click

The Object Identification Center (OIC) represents another advanced tool for handling complex object identification scenarios. This dedicated interface allows testers to create, modify, and manage object identification settings with precision. The OIC provides granular control over which properties are used for identification, how ordinal identifiers are applied, and whether smart identification should be employed. By configuring these settings through the OIC, testers can develop identification strategies tailored to their specific application requirements.

For particularly challenging scenarios, testers can develop custom identification solutions using programming extensions. UFT supports the creation of custom identification mechanisms through its COM interface and SDK. This approach allows testers to implement specialized logic tailored to their application's unique requirements, potentially incorporating machine learning algorithms or other advanced techniques to identify objects based on multiple criteria.

Best Practices for Robust Object Identification

Developing robust object identification strategies requires both technical knowledge and thoughtful testing practices. The following guidelines can help ensure your tests remain stable despite application changes:

1. Prioritize stable properties that are less likely to change between application versions

2. Use multiple identification properties when possible to create redundancy

3. Implement consistent naming conventions for custom controls

4. Regularly review and update object identification settings

5. Create documentation for complex identification strategies

When working with custom controls, invest time in understanding their underlying architecture and behavior. This knowledge will help you identify the most reliable properties for recognition and anticipate potential issues before they impact your tests. For complex UI patterns, consider modularizing your identification logic into reusable functions or components that can be easily maintained and updated.

Effectively managing custom controls in UFT requires adherence to several best practices that ensure test reliability and maintainability. These practices help testers develop robust automation strategies that can withstand changes in the application while providing consistent results across different environments and test runs.

One fundamental best practice is to establish a standardized approach to object identification early in the automation project. This standardization should include guidelines on which properties to prioritize, when to use descriptive programming versus the object repository, and how to document identification strategies. By creating a consistent methodology across the team, testers can reduce confusion, improve collaboration, and ensure that tests remain maintainable as the application evolves.

Another critical practice is to minimize the use of hardcoded values in test scripts. When dealing with custom controls, it's often tempting to use specific property values that work in the current test environment. However, this approach creates brittle tests that are likely to fail when the application changes or when tests are run in different environments. Instead, testers should use parameters, configuration files, or external data sources to manage dynamic values, making tests more resilient to changes.

Key best practices for custom control handling:

  • Establish consistent identification methodologies
  • Minimize hardcoded values through parameterization
  • Implement proper error handling for identification failures
  • Regularly review and update identification strategies
  • Document all custom control handling approaches

Proper error handling represents another essential best practice when working with custom controls. Since these elements can be unpredictable, tests should include mechanisms to handle identification failures gracefully. This might involve retry logic, alternative identification methods, or conditional statements that account for different application states. By implementing robust error handling, testers can create tests that continue to execute even when certain elements are not immediately available, improving test stability and reducing false failures.

Maintenance is a critical aspect of object identification. As applications evolve, so too must your identification strategies. Establish a process for periodically reviewing and updating object identification settings, particularly after major application updates or releases. This proactive approach can prevent identification failures and ensure your tests continue to provide reliable feedback.

Troubleshooting Common Object Identification Issues

Despite careful planning and implementation, testers often encounter object identification issues that can compromise test reliability. Understanding how to troubleshoot these problems effectively is essential for maintaining a stable automation framework and ensuring that tests continue to function as the application evolves.

One common issue is the "object not found" error, which occurs when UFT cannot locate an element during test execution. This problem typically stems from changes in the application's structure or properties that are not reflected in the object repository or test scripts. To address this issue, testers should first verify that the object still exists in the application and then determine which properties have changed. Using the Object Spy to examine the current properties of the problematic object can reveal discrepancies that need to be addressed in the identification strategy.

Another frequent challenge is the "ambiguous object" error, which occurs when UFT identifies multiple objects with the same properties. This situation often arises when dealing with dynamically generated elements or when application features create objects with similar characteristics. To resolve this issue, testers can employ several techniques, including adding ordinal identifiers, using regular expressions to distinguish between similar objects, or incorporating additional properties that uniquely identify the target element.

Troubleshooting approaches include:

  • Using the Object Spy to examine object properties
  • Implementing wait statements for dynamic content
  • Adding error handling for identification failures
  • Regularly updating object repositories

Timing issues represent another common category of object identification problems. Modern web applications often include dynamic content that loads asynchronously, causing elements to appear at different times during test execution. When tests attempt to interact with elements before they are fully loaded, failures can occur. To address this issue, testers should implement appropriate synchronization points or wait statements that ensure elements are ready before interaction. UFT provides several built-in wait mechanisms, as well as the ability to create custom synchronization logic tailored to specific application requirements.

For persistent identification issues, testers may need to reconsider their overall approach to object identification. This might involve switching from the object repository to descriptive programming, implementing custom identification logic through programming extensions, or utilizing the Object Identification Center to configure more sophisticated identification strategies. By taking a step back and evaluating the fundamental approach to object identification, testers can often discover more effective solutions to challenging identification scenarios.

Conclusion

Mastering object identification in UFT, particularly when dealing with custom controls and complex UI patterns, is essential for building reliable and maintainable automated tests. By understanding UFT's identification framework, implementing advanced techniques, and following best practices, testers can overcome the challenges posed by modern applications with sophisticated UI elements. The ability to consistently identify and interact with these elements forms the foundation of successful test automation, ensuring that tests remain effective as applications evolve and change.

The investment in developing sophisticated identification strategies pays dividends through more reliable tests, reduced maintenance overhead, and greater confidence in your automation efforts. As technology continues to advance, the importance of robust object identification strategies will only grow, making it a critical skill for anyone working with UFT and automated testing. By leveraging tools like the Object Identification Center, implementing techniques such as descriptive programming and regular expressions, and adhering to best practices for maintenance and documentation, testers can create automation frameworks that withstand the test of time and application changes.

Frequently Asked Questions

  • What is UFT's object identification framework?
    UFT's object identification framework uses the Test Object Model (TOM) to map application objects to test objects. It employs mandatory properties, assistive properties, and ordinal identifiers to locate elements reliably.
  • How does UFT handle custom controls?
    UFT handles custom controls through the Object Identification Center, allowing testers to add custom properties. For complex scenarios, descriptive programming and regular expressions provide more flexible identification approaches.
  • What is Smart Identification in UFT?
    Smart Identification is a fallback mechanism that uses 'base filter' and 'associated' properties when default identification fails. It provides a more flexible approach to uniquely identify objects when standard properties are insufficient.
  • How can I troubleshoot object identification issues in UFT?
    Use the Object Spy to examine current properties, implement wait statements for dynamic content, and add error handling for identification failures. Regularly updating object repositories also helps maintain identification accuracy.
  • What are best practices for robust object identification?
    Prioritize stable properties, use multiple identification properties for redundancy, implement consistent naming conventions, and regularly review identification settings. Document complex strategies for team collaboration.

No comments:

Post a Comment