Descriptive Programming

Descriptive Programming Explained

Descriptive programming is a technique used in software development, particularly in Automated UI Testing (AUT) frameworks. It allows testers to define actions on user interface (UI) elements using natural language-like descriptions instead of relying solely on technical identifiers.

Here’s a breakdown:

  • Traditional Approach: In traditional AUT, testers interact with UI elements using technical identifiers like object names, IDs, or coordinates. This can be difficult to understand and maintain, especially for those without deep coding knowledge.
  • Descriptive Programming Approach: With descriptive programming, testers describe the UI element and the action to be performed in a more readable way. This could be something like “Click the button labeled ‘Submit’” or “Enter ‘John Doe’ in the text field labeled ‘Name’”.

Significance and Effectiveness

Descriptive programming offers several advantages:

  • Improved Readability: Test scripts become easier to understand for everyone, including testers, developers, and stakeholders. This makes collaboration and troubleshooting much smoother.
  • Reduced Maintenance: Since the focus is on functionality rather than technical details, scripts are less likely to break when UI elements change slightly. This saves time and effort during maintenance.
  • Increased Accessibility: Testers with less coding experience can write and understand tests more easily, expanding the pool of potential testers.

However, it’s important to consider some limitations:

  • Limited Flexibility: Descriptive programming might not be suitable for very complex interactions or elements with dynamic behavior.
  • Framework Dependence: The effectiveness of descriptive programming depends on the specific AUT framework and its capabilities for interpreting natural language descriptions.

How it’s Done

The exact implementation of descriptive programming varies depending on the AUT framework being used. Here’s a general overview:

  1. Identify UI Elements: Testers use the framework’s tools to identify the UI elements they want to interact with. This might involve using visual aids or properties of the element.
  2. Describe Actions: Instead of writing code to manipulate the element, testers use keywords and natural language descriptions to specify the action. Some frameworks offer pre-defined keywords like “click,” “enter text,” or “select.”
  3. Execute the Script: The AUT framework interprets the descriptive script and performs the actions on the identified UI elements.

Here’s a simple example (pseudocode):

  • Traditional Approach:
Click(FindElement(name="submitButton"));
  • Descriptive Programming Approach:
Click the button labeled "Submit";

Overall, descriptive programming is a valuable technique for improving the readability, maintainability, and accessibility of UI tests. While it might not be a perfect solution for every scenario, it can significantly streamline the AUT process for many projects.