Descriptive programming in QTP.
Descriptive programming is the smartest way for automation in QTP.
Descriptive programming in QTP is much different from simple record and play method.
Following are some important points regarding descriptive programming in QTP.
- It doesn’t require recording the page and so no need worry about object repository.
- You can optimize your code.
- Before starting descriptive programming you need to know about object properties and their values, using object spy you can see each object’s properties.
Let’s learn descriptive programming in qtp in a very simple and practical way.
I have given 3 different examples which uses different method for automation in QTP.
Using object repository method: Example 1
Following QTP script is the simple example of record and play method.
Now, you want to write above script in descriptive programming. For that you need to get all object properties using “object spy” tool. E.g Browser is the parent object and its property is “Name=Google” and Page is the child object whose property is “Title=Google”.
Now understand following example which is the combination of “record & play” and “descriptive programming” method. You can say hybrid programming.
Hybrid programming: Example 2
Note: Don’t copy and paste and try to run above examples because it requires object repository to execute.
Now at this point you may be very well aware of hybrid programming (combination of descriptive programming and using object repository method).
Following is the example of pure descriptive programming in QTP which you can copy and paste to QTP (Tested with QTP 10 and IE 8) and can execute it.
Descriptive programming in QTP: Example 3
‘Write ‘quicklearnqtp’ in search box
GooglePage.WebEdit(“name:=q”,”type:=text”,”html tag:=INPUT”).Set “quicklearnqtp”
‘Click on Google Search
GooglePage.WebButton(“name:=Google Search”,”index:=0″,”type:=submit”,”html tag:=INPUT”).Click
I hope you gained a lot on descriptive programming technique from this post.I will provide more real time examples and details on descriptive programming in QTP in my next post. Let me know your inputs on descriptive programming in QTP and share your feedback.
If you like this article, You can subscribe through mail.