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.
 

Syntax:TestObject("PropertyName1:=PropertyValue1","....","PropertyNameX:=PropertyValueX")

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

Note:
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.
Example:
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).Activate
Dialog(Login).WebEdit(Agent).Set "STC"
Dialog(Login).WebEdit(Pwd).SetSecure password
Dialog(Login).WinButton(OK)

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.

Steps:
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
Ex:Dialog(Login).Activate

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:"
oOK("text").value="OK"

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

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.

Wednesday, 26 December 2012

QTP Settings Global Configuration

This article explains the details about the object identification and configuration.
 

As we know that there are around 25-30 object properties are available for each object in QTP. But QTP recognizes them by using only 2 to 3 properties.

By default QTP has certain configuration for each environment. We can add more properties if we feel that the default properties are not enough to identify the object.

In this article am going to explain the various object identification configurations available in QTP.

01.Normal Identification:
In this type of configuration,QTP uses two types properties to identify the object uniquely.
   a. Mandatory Properties
   b. Assistive Properties
In this configuration,QTP learns all mandatory properties at a time and thinks whether these properties are sufficient to identify the object uniquely. If it feels the properties are sufficient to identify the object uniquely then it stops learning.Otherwise,it learns the first assistive property once and stops and thinks and keep on repeating the steps until the object is uniquely identified.At the end of the assistive properties if QTP feels that the properties are not sufficient it finally goes to Ordinal Identifier.

02.Smart Identification:
In this type of configuration, QTP uses two types of properties to identify the object uniquely.
  a.Base filter properties
  b.Optional properties
This is an optional configuration.If we feel that the normal configuration is not enough to identify the object we can go for Smart Identification configuration. In this QTP learns all base filter properties at a time and thinks whether the properties are sufficient to recognize the object uniquely.If QTP feels the properties are sufficient then it stop learning.Otherwise, it goes to the optional filter properties and learns one by one.Then QTP keep on repeating the same step if it feel the properties are not sufficient. At the end of the assistive properties if QTP feels that the properties are not sufficient it finally goes to ordinal identifier.

03.Ordinal Identifiers:

We have 3 types of Ordinal Identifiers in QTP.
   a.Index
   b.Creation Time
   c.Location

Index: This one is based on the sequence of the programs. It starts from Zero.
Creation Time:This one is based on the loading time of the web objects.It starts from Zero.
Location: This one is based on the object location on the AUT. It starts from Zero.

Settings:
Since QTP is a stand alone application, it's is not possible to configure the settings as Global. But QTP is providing a feature called "Generate Script" to configure the settings as Global.
 

01.The settings are available in 3 areas.
    a.File> Settings
    b.Tools> Options
    c.Tools> Object Identification
02.Configure the required settings and generate scripts.
03.The script should be stored in VBS format and shared with the team members.
04.Launch the generated script across n-number of PCs to get the same settings.

 
Back To Top