Micro Focus QTP (UFT) Forums
No. of Browsers - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: No. of Browsers (/Thread-No-of-Browsers)



No. of Browsers - bfakruddin - 01-12-2009

Hello Friends,

My question is we have no.of browsers opened in our windows, now I need how many browsers opened and what are their names...! and how to close particular browser?

thanx in advance


RE: No. of Browsers - stevol - 01-13-2009

You can use the Description.Create & ChildObjects. For example:

Code:
Set brow = Description.Create()
brow("application version").value="internet explorer 6"
Set browobj = desktop.ChildObjects(brow)
NoOfChildObjs = browobj.Count

msgbox NoOfChildObjs

For Counter=0 to NoOfChildObjs-1
    msgbox browobj(counter).getroproperty("name")
Next

browobj(0).close

that is you build an array [ -> browobj ] in which each element is a browser (and with Description.Create you can better specify the properties)


RE: No. of Browsers - bfakruddin - 01-19-2009

stevol Wrote:You can use the Description.Create & ChildObjects. For example:

Code:
Set brow = Description.Create()
brow("application version").value="internet explorer 6"
Set browobj = desktop.ChildObjects(brow)
NoOfChildObjs = browobj.Count

msgbox NoOfChildObjs

For Counter=0 to NoOfChildObjs-1
    msgbox browobj(counter).getroproperty("name")
Next

browobj(0).close

that is you build an array [ -> browobj ] in which each element is a browser (and with Description.Create you can better specify the properties)

Thanks Stevol,

I will get that no. of browsers opened and their names by using description.create,

Can I close particular browser without using description.create,


RE: No. of Browsers - stevol - 01-19-2009

If you know the properties of this browser, you can identify it (and close it). For example with hwnd property:

Code:
Dim brclose
Set brclose = Browser ("hwnd:=xyz")
brclose.close



RE: No. of Browsers - sreekanth chilam - 01-20-2009

Hi ,

We can close the required browser in the below ways, if at all we know any property(say hwnd=xyz) :

1st way :
Browser ("hwnd:=xyz").close

2nd Way:
systemutil.CloseProcessByHwnd("xyz")


RE: No. of Browsers - bfakruddin - 01-20-2009

Thank You Sreekanth,

I expected 2nd way....!

but, can't we use Systemutil.closeprocessbyname/title("xyz")