Here we discuss 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
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”) and are stored in object repository.
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
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
“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
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”
oGoogleSearch(”type”).Value = “Submit”
oGoogleSearch(”name”).Value = “Google Search”
oGoogleSearch(”html tag”).Value = “INPUT”
Browser(”Browser”).Page(”Google”).WebButton(oGoogleSearch).Click
Difference between string description and Object Description -
String Description
– Uses less memory as strings are used
– Increases statement length in case more than one property is to be used.
– Preferred when property value have regular expression characters which needs to be treated
literally
– Uses less memory as strings are used
– Increases statement length in case more than one property is to be used.
– Preferred when property value have regular expression characters which needs to be treated
literally
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
– 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
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(”Page”).Sync
Browser(”micclass:=Browser”).Navigate “http://www.google.com”
Browser(”micclass:=Browser”).Page(”micclass:=Page”).WebEdit(”name:=q”).Set _
“KnowledgeInbox”
“KnowledgeInbox”
Browser(”micclass:=Browser”).Page(”micclass:=Page”) _
.WebButton(”type:=Submit”, “name:=Google Search”, “html tag:=A”).Click
.WebButton(”type:=Submit”, “name:=Google Search”, “html tag:=A”).Click
No comments:
Post a Comment