0% found this document useful (0 votes)
3K views

Converting or (Object Repository) Based Scripts To Descriptive Programming - Tarun Lalwani

DP Part 2 - Converting OR Based Scripts To DP - By Tarun Lalwani http://knowledgeinbox.com/articles/qtp/descriptive-programming/dp-part-2-converting-or-based-scripts-to-dp/

Uploaded by

Braidy Hunter
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3K views

Converting or (Object Repository) Based Scripts To Descriptive Programming - Tarun Lalwani

DP Part 2 - Converting OR Based Scripts To DP - By Tarun Lalwani http://knowledgeinbox.com/articles/qtp/descriptive-programming/dp-part-2-converting-or-based-scripts-to-dp/

Uploaded by

Braidy Hunter
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Converting OR (Object Repository) Based scripts to

Descriptive Programming
Author(s): (1) tarun_lalwani

Written On: 27-Aug-2005

Keywords:

QTP, Quick Test, Quick Test Pro, Descriptive Programming, Programming Description

Introduction:

This article discusses how we can convert an Object repository based script to DP based
script. For this we will do a simple recording of entering some text on Google.com search
text box and clicking the Google search button

The QTP generated script would look something like below

SystemUtil.Run "C:\Program Files\Internet Explorer\IEXPLORE.EXE"


Browser("Browser").Page("Page").Sync
Browser("Browser").Navigate "http://www.google.com"
Browser("Browser").Page("Google").WebEdit("q").Set "KnowledgeInbox"
Browser("Browser").Page("Google").WebButton("Google Search").Click

All the names used between “” are logical name of the objects in the Object Repository
(”Browser”, “Page”, “Google”, “q”, “Google Search”) as shown in below image
Object Repository for the recorded script

Now let’s look the below statement and try and convert it to DP

Browser("Browser").Page("Google").WebButton("Google Search").Click
Converting WebButton(”Google Search”)

The Google Search object present in the OR has following properties

type = submit

name = Google Search

html tag = INPUT

Now to conver the WebButton(”Google Search”) to its DP counterpart we can use two different
methods

Method 1 – Using String Description


In this we use string parameters to specify the object properties

Browser("Browser").Page("Google").WebButton("type:=Submit", _
"name:=Google Search", "html tag:=INPUT").Click
Method 2 – Using Object Description

In this we first create a description of the object and then use it in the statement

Set oGoogleSearch = Descrition.Create


oGoogleSearch("type").Value = "Submit"
oGoogleSearch("name").Value = "Google Search"
oGoogleSearch("html tag").Value = "INPUT"

Browser("Browser").Page("Google").WebButton(oGoogleSearch).Click
Which method of DP to choose?

The later articles of this DP Part X series would be discussing in details when and where to use
for which method. For now just understand that both methods have their own advantage and
disadvantages

Few difference IMO are listed below

String Description Object Description


Uses less memory as strings are Requires more memory as objects are
used created. Object creation is as such a
overhead
Increases statement length in Increase lines of code due to object creation
case more than one property is to overhead and property assignment
be used
Preferred when property value have regular
expression characters which needs to be
treated literally
(explained in one of the later articles)

DP Converted script
SystemUtil.Run "C:\Program Files\Internet Explorer\IEXPLORE.EXE"

Browser("micclass:=Browser").Page("Page").Sync
Browser("micclass:=Browser").Navigate "http://www.google.com"

Browser("micclass:=Browser").Page("micclass:=Page").WebEdit("name:=q").Set _
"KnowledgeInbox"

Browser("micclass:=Browser").Page("micclass:=Page") _
.WebButton("type:=Submit", "name:=Google Search", "html tag:=A").Click

You might also like