Get active browser or web page
What is QTP Code or syntax to get active browser or web page at any time during run of script?
Lets say I am running my QTP test script on page "http//ABC/xyz/somepage.aspx" at any point of time.
I can view this page manually open the opened browser screen...but how to get that captured using my QTP code
Re: Get active browser or web page
1.Set oD = Description.Create()
oD("micclass").value = "Browser"
Set oDObj = Desktop.childObjects(oD)
''''Perform Operation on the child Objects
''''They are the browser's on the desktop
2. Continued
Set oF = Description.Create
oF("micclass").value = "Frame"
Set oFObj = oDObj(1).ChildObjects(oF)
''''Perform Operations on the Frame in Collection "oFObj"
Regards,
Nawab
Re: Get active browser or web page
One way this can be done is:
[B]Public Sub[/B] BrowserExist()
[B]For[/B] intNumberOfBrowsers = 0 [B]to[/B] 99
[B]If [/B]Browser("creationTime:="&intNumberOfBrowsers).Exist [B]Then[/B]
strChk=[B]True[/B]
[B]Else[/B]
strChk=[B]False[/B]
[B]Exit For[/B]
[B]End If[/B]
[B]Next[/B]
[B]If [/B]strChk = True [B]Then[/B]
[B]msgBox[/B] "" & intNumberOfBrowsers & " Browser(s) Currently Open"
[B]Else[/B]
[B]msgBox[/B] "No Browsers currently Open"
[B]End If[/B]
[B]End Sub[/B]
Usage: [B]Call[/B] BrowserExist()
-------
Another way:
[B]Public Function[/B] chkBrowserExist(creationT)
[B]If[/B] Browser("creationTime:= "&creationT).Exist [B]Then[/B]
strChk = True
[B]Else[/B]
strChk = false
[B]End If[/B]
chkBrowserExist = strChk
[B]End Function[/B]
Usage: [B]Call [/B]chkBrowserExist(0)