Micro Focus QTP (UFT) Forums
How to identify top browser from a lot 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: How to identify top browser from a lot of browsers? (/Thread-How-to-identify-top-browser-from-a-lot-of-browsers)

Pages: 1 2


How to identify top browser from a lot of browsers? - guocnc - 03-01-2009

Hello,
Please read the following script

Code:
Set oDesc = Description.Create()
oDesc("micclass").Value = "Link"
Set Links = Browser("title:=Google").Page("title:=Google").ChildObjects(oDesc)
Msgbox "Total links: " & Links.Count
Links(3).click
Browser("title:=.*").back

When the Browser("title:=.*").back is executed, there is a error message:"The "[ Browser ]" object's description matches more than one of the objects currently displayed in your application. Add additional properties to the object description in order to uniquely identify the object."

How can we identify the current browser after Links(3).click without using additional properties?

Thank you.


RE: How to identify top browser from a lot of browsers? - Ankur - 03-02-2009

Without using additional properties?
May I know why you don't want to use additional properties?

Otherwise you can use an ordinal identifier like 'creation time' to uniquely identify a browser.


RE: How to identify top browser from a lot of browsers? - elsekra - 03-02-2009

I think you have to add "index" property at last , without additional properties , i don't know if it's possible to identify lot off window with the same properties ...


RE: How to identify top browser from a lot of browsers? - guocnc - 03-02-2009

Hello,

What I means is that if after Links(3).click, the browser navigates to a new page and I don't know this new page's properties such as title, name, etc. Then what methods can we use to identify this new page(browser with unknown title and other proterties). If we can identify this new page then we can do something like browser("title of new page").back.

usually the new page should be on the top of a lot of browsers, then how to identify it, or how to identify any top browser on a list of browsers?

Thanks.


RE: How to identify top browser from a lot of browsers? - elsekra - 03-04-2009

In this case add 'location' property in the object repository and set it to 0 . That will resolve your problem


RE: How to identify top browser from a lot of browsers? - VENKATAREDDY_M - 03-04-2009

Hi Guocnc,
Pls take "hwnd" property of that browser.
Use that property to Identify that Browser.

Code:
sHwNd = Links(3).GetROProperty("hwnd")
Links(3).click
Browser("hwnd:=sHwNd").Back

Hope this will work

Thanks
VENKATA REDDY


RE: How to identify top browser from a lot of browsers? - guocnc - 03-05-2009

Thanks for elsekra.
Using object repository must do recording first. I want to use Descriptive programming without object repository.
Thanks for VENKATAREDDY_M,

Link(3) is the collection of link objects. I use Object spy to try to find the property hwnd of link object, but I can not find it. How to find it?

I am thinking maybe we can use property:createtime of Browser object to identify the top browser


RE: How to identify top browser from a lot of browsers? - papu - 03-05-2009

Hwnd property is availabe for page and browser object.find hwnd property at this object level only...


RE: How to identify top browser from a lot of browsers? - sreekanth chilam - 03-05-2009

HI guocnc,

Try with the below code ..... Your requirement will be solved now ...Smile

Code:
Set PDesc=Description.Create
        PDesc("micclass").Value="Page"
  Set LDesc=Description.Create
        LDesc("micclass").Value="Link"

   Set Pages=Browser("CreationTime:=0").childObjects(PDesc)
   Set Links=Pages(0).ChildObjects(LDesc)
   Links(3).Click
   Browser("CreationTime:=0").Back



RE: How to identify top browser from a lot of browsers? - guocnc - 03-05-2009

Thanks for sreekanth chilam
CreationTime:=0 only identifies the first browser in a desktop instead of the top browser except that there is only one browser in a desktop.
I do it in another similar way. First calculate the total no of the browsers, then the top browser is the CreationTime:=total-1. I don't know whether there is any exception for this solution which works in normal conditions. Please see the following code.

Code:
Set oDesc = Description.Create()
oDesc("micclass").Value = "Link"
Set Links = Browser("title:=Google").Page("title:=Google").ChildObjects(oDesc)
Links(3).click

Dim oDescB
Set oDescB=Description.Create()
oDescB("micclass").Value="Browser"
Set oDescB = DeskTop.ChildObjects(oDescB)

Browser("CreationTime:=" &  oDescB.count-1).back

Set oDescB=nothing
Set Links=nothing