1
votes

I am using QTP 10 and QTP is showing the result as true even if only one browser instance is open. I have Internet Explorer open (only one instance) and no other browser is open. If I execute the below code with different values of "creationtime", then the result is always true. Is this an issue?

Set myB=Browser("creationtime:=2")
If not  myB.Exist Then
    print "False"
    else
    print "True"
End If

The result is always true if you have only one instance of the browser open and you change the creation time. I mean for creation time 0, 1, 2...n - the result is always shown as true.

1
May be there are some instances of the Browser running but not visible. To verify that, open up the Task Manager processes and see if there are multiple instances of "iexplore.exe" running or not. - Gurmanjot Singh

1 Answers

1
votes

CreationTime is an ordinal selector, this means it's used only if there is ambiguity as to what object is described. Since in your case Browser is in itself a unique description (there is only one browser), the ordinal will not be used.

If you want to know how many browsers exist you have to take a different route (note: I'm not sure this will work correctly when used with mobile browsers).

Set desc = Description.Create()
desc("micclass").Value = "Browser"
Set browsers = Desktop.ChildObjects(desc)
Print "Browser count = " & browsers.Count