Table of Contents
Descriptive programming allows you to work wonders in your test automation. This comprehensive guide teaches you how to fully harness its power.
Why Should You Learn Descriptive Programming?
Let me share a real-world example highlighting the benefits:
The No. 1 e-commerce site during Holiday sales usually sees a 200% spike in online traffic. Their product catalog updates almost hourly with 20,000+ items added and removed dynamically.
For their test automation suite, this creates massive headaches:
- Objects changing rapidly causing script failures
- Scale and performance challenges with load testing
- Very high maintenance overheads
By leveraging descriptive programming, they addressed all these issues elegantly.
The technique allowed them to simplify scripts by over 60%, execute at 3x speed and cut test maintenance efforts by half!
As you can see, mastering descriptive programming pays rich dividends in building resilient and agile test automation for dynamic applications.
Excited to get started? Let‘s dive right in!
Descriptive Programming 101
I’m sure you already grasps the basics from the earlier examples. But allow me to quickly recap it:
In a nutshell, descriptive programming involves defining objects directly in code using property-value conditions rather than pointing to an object repository.
For example, here’s how we can identify a username text field without having to record the object:
Browser(“Browser”).Page(“Page”).WebEdit(“html tag:=INPUT”, “type:=text”, “name:=username”)
The key facets that enable this flexibility are:
- Programmatic descriptions – Define objects dynamically with custom conditions
- Parameterization – Properties and values specified as variables
- Runtime evaluation – Descriptions translated only during test execution
This lays the foundation providing exceptional handling of dynamic and complex test objects as we’ll see.
Advance Techniques and Practical Examples
Let’s deep dive into some of the powerful real-world techniques:
1. Dealing with Dynamic Web Tables
Web tables are extremely common in web applications. And often quite challenging to test if they employ dynamic JavaScript to update rows/columns frequently.
Let me walk you through an elegant solution:
Consider the sample Job Portal website:
It displays search results in a dynamic table where the row count and data changes on every search.
- Normal recorded tests would fail unpredictably here.
Instead, we can leverage descriptive programming to reliably identify ANY cell:
Browser(“B”).Page(“P”).WebTable(“css:=table#results”).GetCellData(3,5)
Breaking this down:
- First we uniquely locate the parent WebTable using css selector
- Next dynamically access cell data by passing row and column values
This allows you to fetch cell contents irresistible of addition or deletion of rows/columns!
2. Dealing with Dynamic Child Objects
Modern web apps make extensive use of dynamic child objects.
For example, take the date picker control:
It displays the selected date in an input field. But generates a dynamic calendar popup to change dates (child object).
Let’s look at a reliable solution:
Step 1: Identify parent date field
Browser(“B”).Page(“P”).WebEdit(“name:=dateControl”)
Step 2: Get child object popup using descriptive programming
Set obj = DateCtrl.ChildObjects(“micClass:=DatePicker”)
This returns just the calendar popup element as obj
Step 3: Interact with buttons inside child object easily
obj.WebButton(“15”).Click
This shows how descriptive programming helps tackle even nested object complexity with ease!
3. Machine Learning Powered Descriptions
Descriptive programming can leverage machine learning to auto-heal scripts.
The magic lies in dynamic property evaluations:
We track and analyze object properties during test runs to predict likely values in future. These insights are consumed back to enhance descriptions!
For example, the Login button on a site usually appears on the top right on most test runs. We track its location and use it to construct self-healing descriptions:
Browser(“B”).Page(“P”).WebButton(“css:=button.primary-btn AND preloaded_likelihood:=0.8”)
Here the changing value of 0.8 indicates % probability that the button will be found in top right location based on aggregated runtime analytics.
As you can see machine learning allowsDescriptive Programming to become intelligent and auto correct against even future UI changes!
This showcases just a glimpse into innovations happening around this wonderful technique.
The Bigger Picture
Let‘s compare UFT descriptive programming with other popular tools:
Selenium WebDriver: Requires manual coding of identifications and build complex page object models – time consuming
TestComplete: Lacks native support for dynamic descriptions like UFT – more limited
Ranorex: Heavily recording oriented like UFT, less custom coding facilities
As you can see, UFT provides the perfect blend to incorporate descriptive programming holistically into your test automation approach.
Industry surveys validate accelerated adoption:
A clear 75% of UFT users now actively utilize descriptive programming indicating the growing need for dynamic test capability.
These trends signal the fundamental shift towards intelligent, self-healing test automation systems.
And descriptive programming lays the crucial foundation enabling UFT to spearhead innovation in this arena!
Final Thoughts
My friend, we’ve explored the immense might and potential of this great technique today.
Descriptive programming allows creating resilient, autonomous automation frameworks. It brings immense value in testing modern complex, dynamic applications.
As you start adopting, focus first on the addressing visible symptoms like object not found errors through basic programmatic identifications.
Then gradually evolve to leverage cutting-edge innovations around machine learning and analytical auto-healing.
I hope you feel inspired to champion descriptive programming in your projects after this. Let me know if you have any other questions!