DP Part 2 - Converting OR Based scripts to DP 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

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 Uses less memory as strings are used Increases statement length in case more than one property is to be used

Object Description Requires more memory as objects are created. Object creation is as such a overhead Increase lines of code due to object creation overhead and property assignment 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

Note: We will discuss more in details about micclass used above in later articles