Descriptive Programming in HP QTP

In this blog, we will see about Descriptive Programming in HP QTP and some sample codes which helps you to learn and practice.

What is Descriptive Programming?

By default, QTP recognizes everything as an object. Each object’s properties, methods, and values get stored in repository called Object Repository. During run-time, QTP try to matches properties and values that are stored in OR with the run-time objects. If it matches, then the QTP performs specified action in the script. If not, QTP throws Object not found error or some appropriate error messages.

Descriptive Programming is one of the approaches that are widely followed in the projects which help automation engineers to define the property and values on their own to identify the objects during execution.

To define an object using Descriptive Programming approach, use below syntax:

Set myObj = Description.Create()

To define the object properties and values, use below syntax:

Objectname(“property_type”).value = “property_value”
myObj ("Name").Value = "userName"

myObj ("Index").Value = "0"

Next step is to define the action. Action can be defined using respective methods for the defined objects.

Browser(“QAInsights”).Page(“QAInsights”).WebEdit(myObj).Set “QAInsights”

Above syntax enters the text “QAInsights” in username field. The same can be achieved using value pairs i.e. propertyname:=propertyvalue.

i.e. classname(“propertytype:=propertyvalue”)

e.g.

Browser(“title:=QAInsights”).Page(“name:=QAInsights”).WebEdit(“name:=userName”,”index:=0”).Set “QAInsights”

Thanks for visiting QAInsights! Check out our new portal Testifications.com to get updates on Software Testing related certifications. We’re always posting interesting articles on QAInsights. I request you to subscribe so you don’t miss out anything. Searching for QA Jobs Openings, check it at www.QAJobOpenings.com

Want to start a blog like this, please visit SpidyDomain to buy cheap web hosting and register domain.

Subscribe to our QAInsights YouTube Channel | Subscribe our free weekly newsletter.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Learn Kubernetes and Get Certified in CKAD.SHOW ME HOW
+ +
Share via
Copy link