Below example shows how we can handle multiple open browsers in QTP.
'Create the browser object using description.create
Set browserObject= Description.Create()
browserObject("micclass").Value= "Browser"
'using Desktop.ChildObjects find the collection of all open browsers
Set collection= Desktop.ChildObjects(browserObject)
'print the total number of open browsers in the system
print "Total number of browsers open in the system are " & collection.Count()
Once we get total number of browsers open in the system. We can print the titles using 2 ways.
For i =0 To (collection.Count()-1)
print "Title of the browser no : " & ( i+1) & " is -> " & collection(i).GetROProperty("title")
Next
Just the another way to print the title of browsers.
For i =0 To (collection.Count()-1)
print "Title of the browser no : " & ( i+1) & " is -> " & Browser("index:=" & i).getROProperty("title")
Next
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts. You can write to me at reply2sagar@gmail.com
'Create the browser object using description.create
Set browserObject= Description.Create()
browserObject("micclass").Value= "Browser"
'using Desktop.ChildObjects find the collection of all open browsers
Set collection= Desktop.ChildObjects(browserObject)
'print the total number of open browsers in the system
print "Total number of browsers open in the system are " & collection.Count()
Once we get total number of browsers open in the system. We can print the titles using 2 ways.
For i =0 To (collection.Count()-1)
print "Title of the browser no : " & ( i+1) & " is -> " & collection(i).GetROProperty("title")
Next
Just the another way to print the title of browsers.
For i =0 To (collection.Count()-1)
print "Title of the browser no : " & ( i+1) & " is -> " & Browser("index:=" & i).getROProperty("title")
Next
We can also print other details of each browser like
- hasmenubar - returns true if browser has menu bar
- hasstatusbar - returns true if browser has statusbar
- hastoolbar - returns true if browser has toolbar
- hwnd - returns the handle of the browser window
- number of tabs - returns the count of tabs
- openedbytestingtool - returns true if the browser is opened by QTP
- opentitle - returns the open title
- openurl - returns the url
Above code was tested on QTP 10 and Internet Explorer 10.
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts. You can write to me at reply2sagar@gmail.com
No comments:
Post a Comment
Please Leave your reply. We value your feedback and inputs