Thursday, 27 December 2012

Descriptive Programming In QTP

This article provides the details about:

  • Introduction to Descriptive Programming 
  •  Advantages of Descriptive Programming
  • Writing Descriptive Programming
  • When and Where to use the Descriptive Programming
  • Points to note with Descriptive Programming

Introduction to Descriptive Programming:
Descriptive programming is mainly used to perform the actions on objects which are not present in the object repository or we can simply tell that the entering/providing the object information directly into the test script is called Descriptive Programming.

Advantages of Descriptive Programming:
01.Maintenance is easy as the resources are less.
02.Script are portable as we can run the scripts from any machine.
03.We can start the test execution process before the application is ready.

Wring Descriptive Programming:
We have 2 ways to write the Descriptive programs.

01.Static Programming / Giving the description in the form of string arguments.
02.Dynamic Programming / Creating properties collection object for the description.

01.Static Programming:
This is most commonly used method in which the object description is directly passed into the script by specifying the "property:=value" pairs.It directly describes the object instead of specifying an object's name.


InvokeApplication "c:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set "STC"
Dialog("text:=Login").WinEdit("attached text:=Password:").SetSecure password

Dialog,WinEdit,WinButton  - Test objects
text, attached text - Property Names
Login,Agent Name:, Password:, - Property Values - Represents the logical names of the objects

If we feel that the property information is not sufficient to identify the object uniquely we can add more property information.If we want to get the object names we can use object spy feature which is present in the object repository manager.
If we want to maintain the objects information in a centralized location then we can use Constants.
Const Login="text:=Login",Agent ="attached text:=Agent Name:"
Const Pwd ="attached text:=Password:", WBut ="text:=OK"

Note:We can declare n-number of contants in a single line separated by comma(,). But we need to use the word Const if we are going for a new line.

Creating Library:
01.Copy the above declared constants to a notepad and save it as a .vbs file.
02.Associate the vbs file to File> Settings> Resource> Click (+) icon> Browse the path of the vbs file and select the vbs file and then click on Apply, OK buttons or the library file can be loaded dynamically.

Syntax: ExecuteFile "path of the vbs file"
Example Of Creating Script using constants:
InvokeApplication("c:\Program Files\HP\QuickTest Professional\
Dialog(Login).WebEdit(Agent).Set "STC"
Dialog(Login).WebEdit(Pwd).SetSecure password

Advantages of the static programming: The main advantage of using library in static programming is that the changes can be easily done as the variable are declared in a common location.

02.Dynamic Programming:
This is also similar to the static programming. But the only difference is that it collects all the properties of a particular object in an instance of that object.By using that the object can be referenced easily by using the instance instead of the string arguments.

01.Create the description of the object.
Syntax:Set Variable=Description.Creare
Ex: Set Login = Description.Create
02.Enter properties information into the description of the object.
Syntax: Variable("Property Name").value ="Property Value"
Ex:Login("text").value = "Login"
03.Generating statements using description objects
Syntax:TestObject(Description Object").Method

Creating propeties Collection Of Objects:
Set oLogin = Description.Create
Set oPassword = Description.Create
Set oUname = Description.Createc
Set oOK = Descrption.Creae

Enter the properties information into objetcs:
oUname("attached text").value="Agent Name:"
oPassword("attached text').value ="Password:"

Generating Tests using properties collection objects:
InvokeApplication "c:\Program Files\ HP\ QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog(oLogin).WinEdit(oUname).Set "STC"
Dialog(oLogin).WinEdit(oPassword).SetSecure password

We can create the library files like static programming by following the below mentioned steps.

01.Create description objects and put into one library, by associating that library file,we can generate tests.
02.Dynamic programming is little bit difficult in preparation that the static programming but maintenance is easy.


alvina brown said...

I blog often and I truly appreciate your content.The article has truly peaked my interest. I'm going to take a note of your blog and keep checking for new details about once per week. I subscribed to your RSS feed too....
software testing in indore

softwaretestingjunction said...

@ alvina brown thanks a lot for your appreciation. Please leave your valuable comments which will be helpful in improving the contents.

Post a Comment

Back To Top