How to find out the count of open browsers by using QTP?

In my application, when we click on some links it opens a new browser. I want to know how many browsers are open at a particular time.

Showing Answers 1 - 12 of 12 Answers

Sycho

  • Nov 21st, 2007
 

Hi,

You can do this by using Browser Identification Property CREATION TIME. Creation Time is an ordinal identifier that QTP assigns to the browser to indicate the order in which the browser was opened relative to other open browsers.

Cheers
SYCHO the great

  Was this answer useful?  Yes

ramupalanki

  • Feb 25th, 2008
 

Below is the answer to ur question

Set BrowserObj = Description.Create
BrowserObj("micclass").Value = "Browser"
Set Obj = Desktop.ChildObjects(BrowserObj)
Msgbox Obj.Count

Let me know if am going in wrong direction



  Was this answer useful?  Yes

Hey, I find this question in many places.

This piece of code works really fine for me.

Set iedesc = description.Create
iedesc("application version").value = "internet explorer 6"
Set iecoll = desktop.ChildObjects(iedesc)
cnt = iecoll.count
set g1 = Datatable.GetSheet("Global")
g1.Addparameter "Count"," "
g1.Addparameter "Browser_name"," "
g1.Addparameter "Window_handle", " "
'msgbox cnt
For i = 0 to (cnt-1)
datatable.SetCurrentRow(i+1)
Datatable("Count",dtglobalsheet) = i
Datatable("Browser_name",dtglobalsheet) = iecoll(i).GetROProperty("title")
Datatable("Window_handle",dtglobalsheet) = iecoll(i).GetROProperty("hwnd")
Next
Set iedesc = nothing
Set iecoll = nothing
cnt1 = cnt
For j = 1 to (cnt1-1) ' I am closing all the browsers except for one.
datatable.SetCurrentRow(j)
  var1 = datatable("Window_handle",dtglobalsheet)
Window("hwnd:= " & var1).close
Next

  Was this answer useful?  Yes

Anwar

  • Aug 18th, 2015
 

But the above script shows an addition count. i.e. when only four browser are opened it shows the count as 5. Is it because I have also kept opened Chrome?

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions