Tuesday 18 February 2014

How to find the title of all open browsers in QTP?

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

We can also print other details of  each browser like
  1. hasmenubar - returns true if browser has menu bar
  2. hasstatusbar - returns true if browser has statusbar
  3. hastoolbar - returns true if browser has toolbar
  4. hwnd - returns the handle of the browser window
  5. number of tabs - returns the count of tabs
  6. openedbytestingtool - returns true if the browser is opened by QTP
  7. opentitle - returns the open title 
  8. 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

Best QTP Books

Everything About QTP

Hello Friends,
You can find QTP study material, Multiple choice questions (mcq), QTP question bank, QTP question papers, QTP notes, QTP questionnaire, scenario based QTP interview questions, QTP tutorial and QTP training on this site.

If you are a fresher or experienced QTP professional with (1/2/3/4) years of experience, this blog is just for you.