İstanbul evden eve nakliyat Beylikd¨¹z¨¹ evden eve nakliyat Tuzla evden eve nakliyat
How to enhance Tests with Descriptive Programming in QTP
Delicious Bookmark this on Delicious
software testing genius

How to enhance Tests with Descriptive Programming in QTP

Welcome to “Software Testing Genius”. Subscribe to my RSS feed for latest content on Software Testing.

How to enhance Tests with Descriptive Programming in QTP

A) Interact with Test Objects not stored in the Object Repository

You can also instruct QTP to perform methods on objects without referring to the Object Repository, without referring to the object’s logical name. To do this, you provide QTP with a list of properties and values that QTP can use to identify the object or objects on which you want to perform a method.

Such a programmatic description can be very useful if you want to perform an operation on an object that is not stored in the object repository. You can also use programmatic descriptions in order to perform the same operation on several objects with certain identical properties, or in order to perform an operation on an object whose properties match a description that you determine dynamically during the test run.

Arial, Helvetica, sans-serif">There are two types of programmatic descriptions.

1) You can either list the set of properties and values that describe the object directly in a test statement,

2) or you can add a collection of properties and values to a description object, and then enter the description object name in the statement.

Entering Programmatic Description Directly into Test Statements:

You can describe an object directly in a test statement by specifying property:=value pairs describing the object instead of specifying an object’s logical name.

The general syntax is:

TestObject("PropertyName1:=ProperyValue1", "..." , "PropertyNameX:=ProperyValueX")

TestObject—the test object class.

PropertyName:=PropertyValue—the test object property and its value.
Each property:=value pair should be separated by commas and quotation marks.

For Example:

Window("Text:=Myfile.txt - Notepad").Move 50, 50

If you want to use the same programmatic description several times in one test, you may want to assign the object you create to a variable.

For Example:

Set MyWin = Window("Text:=Myfile.txt - Notepad")

MyWin.Move 50, 50

Using Description Objects for Programmatic Descriptions:

You can use the Description object to return a Properties collection object containing a set of Property objects. A Property object consists of a property name and value. You can then specify the returned Properties object in place of a logical name in a test statement.

To create the Properties collection, you enter a Description.Create statement using the following syntax:

Set MyDescription = Description.Create()

Once you have created a Properties object (such as MyDescription in the example above), you can enter statements to add, edit, remove, and retrieve properties and values to or from the Properties object during the test run. This enables you to determine which, and how many properties to include in the object description in a dynamic way during the test run.

Once you have filled the Properties collection with a set of Property objects (properties and values), you can specify the Properties object in place of a logical name in a test statement.

For example, instead of entering:

Window("Error"). WinButton("text:=OK", "width:=50").Click

You can enter:

Set MyDescription = Description.Create()

MyDescription("text").Value = "OK"

MyDescription("width").Value = 50


Retrieving ChildObjects:
You can use the ChildObjects method to retrieve all objects located inside a specified parent object, or only those child objects that fit a certain programmatic description. In order to retrieve this subset of child objects, you first create a description object and add the set of properties and values that you want your child object collection to match using the Description object.

Note: You must use the Description object to create the programmatic description for the ChildObjects description argument. You cannot enter the programmatic description directly into the argument using the property:=value syntax.

Once you have "built" a description in your description object, use the following syntax to retrieve child objects that match the description:

Set MySubSet=TestObject.ChildObjects(MyDescription)

For example, the statements below instruct QTP to select all of the check boxes on the Itinerary Web page:

Set MyDescription = Description.Create()

MyDescription("html tag").Value = "INPUT"

MyDescription("type").Value = "checkbox"

Set Checkboxes = Browser("Itinerary").Page("Itinerary").ChildObjects(MyDescription)

NoOfChildObjs = Checkboxes.Count

For Counter=0 to NoOfChildObjs-1

Checkboxes(Counter).Set "ON"


Using Programmatic Descriptions for the WebElement Object:
The WebElement object enables you to perform methods on Web objects that may not fit into any other Mercury test object class. The WebElement test object is never recorded, but you can use a programmatic description with the WebElement object to perform methods on any Web object in your Web site.

For example, when you run the statement below:

Browser("Mercury Tours").Page("Mercury Tours").WebElement("Name:=UserName", "Index:=0").Click


set WebObjDesc = Description.Create()

WebObjDesc("Name").Value = "UserName"

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

Browser("Mercury Tours").Page("Mercury Tours").WebElement(WebObjDesc).Click

QTP clicks on the first Web object in the Mercury Tours page with the name UserName.

Using the Index Property in Programmatic Descriptions:

The index property can sometimes be a useful test object property for uniquely identifying an object. The index test object property identifies an object based on the order in which it appears within the source code, where the first occurrence is 0.

Note that index property values are object-specific. Thus, if you use an index value of 3 to describe a WebEdit test object, QTP searches for the fourth WebEdit object in the page.

If you use an index value of 3 to describe a WebElement object, however, QTP searches for the fourth Web object on the page regardless of the type, because the WebElement object applies to all Web objects.

For example, suppose you have a page with the following objects:

1) An image with the name "Apple"

2) An image with the name "UserName"

3) A WebEdit object with the name "UserName"

4) An image with the name "Password"

5) A WebEdit object with the name "Password"

The description below refers to the third item in the list above, as it is the first WebEdit object on the page with the name UserName.

WebEdit("Name:=UserName", "Index:=0")

The following description, however, refers to the second item in the list above, as that is the first object of any type (WebElement) with the name UserName.

WebElement("Name:=UserName", "Index:=0")

B) Access Dynamic Objects during run-time

Retrieving Run-Time Object Properties:

You can use the Object property to access the native properties of any run-time object. For example, you can retrieve the current value of the ActiveX calendar’s internal Day property as follows:

Dim MyDay

Set MyDay=Browser("index").Page("Untitled").ActiveX("MSCAL.Calendar.7").Object.Day

Activating Run-Time Object Methods:

You can use the Object property to activate the internal methods of any run-time object. For example, you can activate the edit box’s native focus method as follows:

Dim MyWebEdit

Set MyWebEdit=Browser("Mercury Tours").Page("Mercury Tours").WebEdit("username").Object


Many More Articles on HP QuickTest Professional 

Download Full Study Material - HP QTP & QC Certification Exams

Practical Roadmap to QTP Certification

Rehearsal of QTP in 1 Hr. -  Interview Questions

What Successful Testers say about the Quality of this website

If you want to keep track of further articles on Software Testing,
I suggest you to subscribe my
RSS feed

You can also Subscribe by E-mail
and get All New articles delivered directly to your Inbox.

Quick Navigation of Software Testing Genius

Get your Absolutely Free Copy of Several MS PowerPoint Presentations & E-Books related to ISTQB, HP Load Runner, IBM RFT, HP QTP & QC Certification Exams, prepared by Popular Writers & Trainers, by writing to:

Full Study Material for International Certification Exams:

Largest Database of Sample Papers - 1000+ Unique Questions for ISTQB Foundation Exam

ISTQB Foundation Exam - Full Crash Course for Download

ISTQB Advanced CTAL Test Analysts Exam - Full Crash Course for Download

ISTQB Advanced CTAL Test Manager Exam - Full Crash Course for Download

Consolidated Study Material - All ISTQB Certification Exams

Practical Roadmap to CSTE Certification

Full Study Material to prepare for other Automation Tools & QA:

Study Material - IBM RFT Certification Exam

Study Material - HP LoadRunner Certification Exams for All Modules

Consolidated Study Material - Testing & QA

Rehearsal of LoadRunner in 1 Hr. -  Interview Questions


Comments :

comments ↓

Leave Your Comments: (*) Marked Fields are Mandatory

You can apply basic formatting to the text

Name *
Email Address *
Speak your mind
sex hikayeleri