What is Descriptive Programming?
Providing Objects information directly into the Test Script, instead of storing objects information in the Object Repository.
Descriptive Programming is a method of performing operation on the object which is not there in Object Repository. We can also use programmatic descriptions to perform the same operation on several objects with certain identical properties, or to perform an operation on an object whose properties match a description that we determine dynamically during the run session.
Tests using Descriptive programming are faster than Tests using Object Repository .
Benefits of Descriptive Programming
If the AUT (Application Under Test) is having Dynamic Objects, then it is better to use descriptive programming. Incase of object repository, it is Difficult to handle dynamic Objects.
When we have more objects to perform operations, in performance point of view descriptive programming is better than object repository method. If we use object repository for generating huge tests, then QTP performance will be decreased , as size of the object repository will increases.
Descriptive Programming is useful if the AUT is having objects that are adding in the Run Time. We can’t add Objects to Object Repository in run time.
If we need to start Test Automation process before the AUT is ready , then Descriptive programming will be very useful.
Descriptive Programming is useful, if the AUT is having similar type of objects or similar name objects. Incase of Object Repository, It will create multiple objects with same description unnecessarily.
Shared Object Repository is not changeable by multiple persons at a time.
Maintenance becomes harder if all the team members have created their own object repositories. In this situation Descriptive Programming is very flexible.
Tests using Descriptive Programming can be executed in any version of QTP without any changes.
Code Portability: Just code is enough to run Tests. We can copy and paste in other scripts for any other required requirement.
Reusing of Properties: We can assign properties to a global variable and reuse it for same type of objects.
Plug & Play: Any time Tests will be in ready to run state. No need to worry about any other settings or files.
Just Maintenance of variables: We can store the object properties in the form of variables in a txt / vbs file which will be placed in central location. In this case we just need to maintain that file.
Types of Programmatic Descriptions (Descriptive Programming)
1) Static: - We enter the set of properties and values that describe the object directly in a VBScript statement.
a) Direct specification of description in script
Browser(“micclass:=Browser”).Page(micclass:=page”).Link(“name:= link”).Click
b) Assigning description to the variables and use that variables in script
g_MainBrowser =“micclass:=Browser”
g_MainPage =“micclass:=Page”
g_Lnk_Login =“name:=Login”
Browser(g_MainBrowser).Page(g_MainPage).Link(g_Lnk_Login).Click
2. Dynamic: - We add a collection of properties and values to a Description object, and then enter the Description object name in the statement.
Set oBrowser = Description.create
oBrowser (“micclass”).value=”Browser”
oBrowser (“name”).value= “Google”
Set oPage = Description.create
oPage (“micclass”).value=”Page”
oPage (“name”).value= “Google”
Set oLink = Description.create
oLink (“name”).value= “Login”
oLink (“index”).value= 1
Browser(oBrowser).Page(oPage).Link(oLink).click
Using the Static type to enter programmatic descriptions directly into your statements may be easier for basic object description needs. However, in most cases, using the Dynamic type provides more power, efficiency, and flexibility.
Handling Runtime added objects / Dynamic Objects / Same Description Objects
Dynamic objects : Property values are getting changed regularly.
Same Description Objects : Property values are same for multiple objects.
Runtime Added Object : Object is not there in recording time but it might be add in runtime.
Eg: Always the job links in timesjob and Monster sites will get update.
Child object method is very useful to get control on Runtime added objects or dynamic objects or same description objects which are there application.
Ex1: If there are multiple signin links on the page, using child objects method we can click on any signin link.