Tuesday, October 13, 2026

UFT Descriptive Programming: Custom Property Filters

Mastering UFT Descriptive Programming: Custom Property Filters and Exclusion Patterns

UFT Descriptive Programming revolutionizes how we approach test automation by providing a flexible method to identify objects beyond the traditional object repository. This powerful technique enables testers to create more resilient and maintainable automation scripts, particularly when dealing with dynamic applications that frequently change their UI structure. By bypassing the Object Repository, Descriptive Programming allows for direct object identification in the script, which can significantly reduce maintenance overhead and improve script execution speed.

Mastering UFT Descriptive Programming: Custom Property Filters and Exclusion Patterns


Understanding Descriptive Programming in UFT

Descriptive Programming (DP) in UFT (Unified Functional Testing) is an approach that allows testers to describe objects in their test scripts using properties and values rather than relying solely on the Object Repository. This technique becomes invaluable when dealing with dynamic applications where objects may change frequently, or when testing applications with numerous similar objects that would otherwise require extensive repository management. DP provides flexibility and scalability, enabling testers to create more robust and adaptable test automation solutions.

The fundamental concept behind descriptive programming is the ability to describe objects using a collection of properties and their corresponding values. Instead of referencing an object by its name in the repository, you explicitly define its characteristics in your test code. This method provides greater flexibility and control over object identification, making your test scripts more adaptable to application changes.

When implementing descriptive programming, you'll typically use the Description object or the ChildObjects method to locate elements. The syntax involves creating a description of the object's properties and then using this description to interact with the application. This approach eliminates dependency on the object repository, which can be particularly beneficial when working with large applications where repository maintenance becomes cumbersome.

There are two primary approaches to DP:

1. Static Descriptive Programming: All properties are defined within the script

2. Dynamic Descriptive Programming: Combines repository objects with additional properties defined in the script for more precise identification

Here's a basic example of Descriptive Programming in UFT:

' Static Descriptive Programming example
Browser("Browser").Page("Page").WebElement("html id:=loginButton", "name:=Submit").Click

' Dynamic Descriptive Programming example
Set objDesc = Description.Create
objDesc("micclass").Value = "WebButton"
objDesc("text").Value = "Login"
Browser("Browser").Page("Page").ChildObjects(objDesc)(0).Click

The Power of Custom Property Filters in Descriptive Programming

Custom property filters represent one of the most powerful features of UFT Descriptive Programming, allowing testers to create precise object identification strategies tailored to their specific application needs. Rather than relying solely on default properties, custom filters enable you to define and prioritize the most relevant properties that uniquely identify objects in your application.

Implementing custom property filters involves selecting properties that provide the most stable and reliable identification criteria. These filters should be chosen based on their uniqueness and resistance to application changes. For example, while a button's text might change between application versions, its HTML ID or CSS class might remain consistent, making it a better candidate for a custom property filter.

The process of creating custom property filters requires a thorough understanding of your application's structure and behavior. You should analyze which properties remain stable across different application states and versions. This analysis helps in building robust test automation that can withstand UI modifications without requiring constant script maintenance.

Key considerations for effective custom property filters:

  • Prioritize properties that are least likely to change between application versions
  • Use combinations of properties when single properties aren't sufficiently unique
  • Consider both visible and technical properties depending on your testing needs
  • Regularly review and update your property filters as applications evolve

Implementing Exclusion Patterns for Robust Test Automation

Exclusion patterns complement custom property filters by allowing testers to explicitly specify which objects should not be considered during identification. This technique is particularly valuable when dealing with complex applications that contain multiple similar objects or dynamic content that changes frequently.

Implementing exclusion patterns involves defining criteria that help UFT differentiate between objects that might otherwise share similar properties. By specifying properties that should NOT match, you can narrow down the object selection process and improve the reliability of your test scripts. This approach is especially useful when working with web applications that generate dynamic content or when dealing with complex UI frameworks.

The syntax for implementing exclusion patterns typically involves the use of special operators or methods within the descriptive programming framework. These operators allow you to define negative criteria that filter out unwanted objects from consideration. When properly implemented, exclusion patterns can significantly reduce false positives and make your test automation more resilient to application changes.

Here's an example of how you might implement exclusion patterns in UFT:

' Create a description for the button
Set btnDesc = Description.Create
btnDesc("micclass").Value = "WebButton"
btnDesc("html tag").Value = "INPUT"

' Add exclusion pattern for buttons with specific IDs to ignore
btnDesc("regexpwndtitle").Value = "^(?!.*ignore_button).*" ' Exclude buttons with "ignore_button" in their ID

' Use the description with exclusion pattern to find the button
Set buttons = Browser("Page").Page("Page").ChildObjects(btnDesc)

This example demonstrates how to use regular expressions to exclude buttons with specific IDs, ensuring that only the relevant buttons are considered during test execution.

Practical Applications and Real-world Examples

UFT Descriptive Programming with custom property filters and exclusion patterns finds extensive application across various testing scenarios. One common use case is in testing web applications with dynamic content, where element IDs or other properties change between application versions or user sessions.

Another practical application is in cross-browser testing, where elements might have different properties or structures across different browsers. By implementing descriptive programming with appropriate filters and exclusion patterns, testers can create scripts that work consistently across different browser environments.

Financial applications represent another domain where descriptive programming excels. These applications often have complex interfaces with numerous similar elements that require precise identification. Custom property filters can help target specific financial instruments or transaction types, while exclusion patterns can help ignore promotional content or temporary UI elements.

Here's a practical example of descriptive programming in a financial application context:

' Create a description for account balance elements
Set balanceDesc = Description.Create
balanceDesc("micclass").Value = "WebTable"
balanceDesc("innerhtml").Value = ".*Account Balance.*" ' Custom property filter
balanceDesc("regexpwndtitle").Value = "^(?!.*Promotional).*" ' Exclusion pattern

' Find and interact with the balance element
Set balanceTable = Browser("Banking App").Page("Dashboard").ChildObjects(balanceDesc)
If balanceTable.Count > 0 Then
    balanceTable(0).Check CheckPoint("Balance Verification")
End If

This example shows how to specifically target account balance elements while excluding promotional content that might have similar properties.

Here's another example demonstrating more complex pattern matching:

' Create a description with advanced regular expression patterns
Set advancedDesc = Description.Create
advancedDesc("micclass").Value = "WebEdit"
advancedDesc("name").Value = "user_.*[0-9]{4}" ' Matches user IDs followed by 4 digits
advancedDesc("regexpwndtitle").Value = "^(?!.*temp_).*" ' Excludes temporary elements

' Find elements matching the advanced description
Set userInputs = Browser("Application").Page("Form").ChildObjects(advancedDesc)

' Process each matching element
For i = 0 To userInputs.Count - 1
    ' Perform actions on each matching element
    userInputs(i).Set "Test Data"
Next

Best Practices for Effective Descriptive Programming

To maximize the benefits of UFT Descriptive Programming, it's essential to follow established best practices that ensure maintainability, reliability, and efficiency. These practices help create test automation that can withstand application changes while minimizing maintenance overhead.

One fundamental best practice is to use the most stable and reliable properties for object identification. Properties that are less likely to change between application versions should be prioritized. This approach reduces the need for frequent script updates and improves test stability. Additionally, using combinations of properties rather than relying on a single property can enhance the robustness of your object identification strategy.

Another important practice is to implement consistent coding standards and naming conventions for your descriptive programming code. This consistency improves readability and makes it easier for team members to collaborate on test automation projects. Documenting your descriptive programming approach and the rationale behind property selections is also crucial for long-term maintenance.

Recommended practices for maintaining descriptive programming code:

  • Regularly review and update property filters as applications evolve
  • Implement modular programming techniques to reuse descriptive code
  • Use version control systems to track changes in descriptive programming implementations
  • Create a centralized library of common object descriptions for consistent usage

Advanced Techniques and Future Trends

As test automation continues to evolve, so do the techniques and approaches associated with UFT Descriptive Programming. Advanced methods are emerging that further enhance the power and flexibility of descriptive programming, making it even more valuable in modern testing environments.

One such advanced technique is the integration of machine learning algorithms with descriptive programming. These algorithms can analyze historical test data to identify the most effective property combinations for object identification, continuously improving the accuracy of test scripts over time.

Another emerging trend is the use of artificial intelligence to automatically generate descriptive programming code based on application behavior. This approach significantly reduces the manual effort required to create and maintain descriptive programming scripts, making test automation more accessible to a broader range of testing professionals.

Here's an example of how you might implement a more advanced descriptive programming technique using regular expressions for complex matching:

' Create a description with advanced regular expression patterns
Set advancedDesc = Description.Create
advancedDesc("micclass").Value = "WebEdit"
advancedDesc("name").Value = "user_.*[0-9]{4}" ' Matches user IDs followed by 4 digits
advancedDesc("regexpwndtitle").Value = "^(?!.*temp_).*" ' Excludes temporary elements

' Find elements matching the advanced description
Set userInputs = Browser("Application").Page("Form").ChildObjects(advancedDesc)

' Process each matching element
For i = 0 To userInputs.Count - 1
    ' Perform actions on each matching element
    userInputs(i).Set "Test Data"
Next

This example demonstrates more sophisticated pattern matching capabilities that can handle complex object identification scenarios.

Conclusion

UFT Descriptive Programming with custom property filters and exclusion patterns represents a powerful approach to creating resilient and maintainable test automation. By understanding and implementing these techniques effectively, testers can build automation frameworks that withstand application changes while providing reliable test coverage.

The combination of custom property filters and exclusion patterns allows for precise object identification even in complex, dynamic applications. This precision reduces false positives and improves test reliability, which are critical factors in any successful automation strategy.

As the testing landscape continues to evolve, mastering descriptive programming will remain an essential skill for test automation professionals seeking to create robust testing solutions. The integration of advanced techniques like machine learning and AI promises to further enhance the capabilities of descriptive programming, making it an even more valuable tool in the tester's arsenal.

By adopting the best practices outlined in this guide and staying informed about emerging trends, test automation teams can leverage the full power of UFT Descriptive Programming to create efficient, maintainable, and reliable test automation solutions that adapt to changing application requirements.

Frequently Asked Questions

  • What is UFT Descriptive Programming?
    UFT Descriptive Programming is an approach that allows testers to describe objects in their test scripts using properties and values rather than relying solely on the Object Repository.
  • How do custom property filters improve test automation?
    Custom property filters enable testers to create precise object identification strategies by prioritizing properties that uniquely identify objects and remain stable across application changes.
  • What are exclusion patterns in UFT Descriptive Programming?
    Exclusion patterns allow testers to specify which objects should not be considered during identification, helping to differentiate between similar objects and reduce false positives.
  • When should I use Descriptive Programming instead of the Object Repository?
    Descriptive Programming is particularly useful for dynamic applications with frequently changing UI, applications with numerous similar objects, or when you need to reduce maintenance overhead.
  • What are best practices for implementing Descriptive Programming?
    Use stable and reliable properties for identification, implement consistent coding standards, regularly review and update property filters, and create modular code for reuse.

No comments:

Post a Comment