Micro Focus QTP (UFT) Forums
Unique Browser identification - 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: Unique Browser identification (/Thread-Unique-Browser-identification)



Unique Browser identification - mca.tarun - 12-11-2009

I am copying two codes where we are not convinced with the output.

Code 1:
Code:
Dim IE
Set IE=createObject("internetExplorer.application")
IE.visible=true
hwndMain=IE.HWND
Window("hwnd:="&hwndMain).Maximize
IE.Navigate "about:blank"
urlToNavigate="www.google.com"
Browser("hwnd:="&hwndMain).Navigate urlToNavigate
Set IE = Nothing

On executing this code, QTP shows error at "Browser("hwnd:="&hwndMain).Navigate urlToNavigate" step. If we change this step to "IE.Navigate urlToNavigate" then it works. On the fly we are creating browser object with some specific hwnd value and it should work.


Code 2:
Code:
Dim IE,IE1
Set IE=createObject("internetExplorer.application")
IE.visible=true
hwndMain=IE.HWND
msgbox hwndMain
Window("hwnd:="&hwndMain).Maximize
IE.Navigate "about:blank"
IE.Navigate "www.google.com"
Set IE1=createObject("internetExplorer.application")
IE1.visible=true
hwndMain1=IE1.HWND
msgbox hwndMain1
IE1.Navigate "www.gmail.com"
Set bDesc = Description.Create()
bDesc("application version").Value = "internet explorer 7"
Set bColl = DeskTop.ChildObjects(bDesc)
Cnt = bColl.Count
MsgBox "There are total: "&Cnt&"browsers opened"
For i = 0 To (Cnt -1)
MsgBox "Browser : "&i&" has title: "& bColl .GetROProperty("title")
Next
Set bColl = Nothing
Set bDesc = Nothing
Set IE = Nothing
Set IE1 = Nothing

On executing this code, message is displayed for 1 opened browser instead of 2. And second thing if we change the "GetROProperty("title")" to hwnd then we got three different hwnd values instead of two.

Can you please look into the issue and correct us at earliest.

Thanks.


RE: Unique Browser identification - sreekanth chilam - 12-12-2009

Hi Tarun,

Check with the below codes, both are working fine as you expectedSmile
Note: I am using IE 6.

Code 1:
Code:
Dim IE
Set IE=createObject("internetExplorer.application")
IE.visible=true
hwndMain=IE.HWND
msgbox hwndMain
Window("hwnd:="& hwndMain).Maximize
IE.Navigate "about:blank"
urlToNavigate="www.gmail.com"
Browser("hwnd:="& hwndMain).Navigate urlToNavigate
Set IE=Nothing

Code 2:
Code:
Dim IE,IE1
Set IE=createObject("internetExplorer.application")
IE.visible=true
hwndMain=IE.HWND
msgbox hwndMain
Window("hwnd:="&hwndMain).Maximize
IE.Navigate "about:blank"
IE.Navigate "www.google.com"
Set IE1=createObject("internetExplorer.application")
IE1.visible=true
hwndMain1=IE1.HWND
msgbox hwndMain1
IE1.Navigate "www.gmail.com"
Set bDesc = Description.Create()
bDesc("application version").Value = "internet explorer 6"
Set bColl = DeskTop.ChildObjects(bDesc)
Cnt = bColl.Count
MsgBox "There are total: "&Cnt&"browsers opened"
For i = 0 To (Cnt -1)
  MsgBox "Browser : "&i+1&" has title: "& bColl(i).GetROProperty("title")
Next
Set bColl = Nothing
Set bDesc = Nothing
Set IE = Nothing
Set IE1 = Nothing

Hope this would solve your issuesSmile


RE: Unique Browser identification - mca.tarun - 12-14-2009

which qtp version u used??? i tried on qtp 10.0


RE: Unique Browser identification - sreekanth chilam - 12-14-2009

Hi,

9.5


RE: Unique Browser identification - mca.tarun - 12-14-2009

why its not working on version 10


RE: Unique Browser identification - sreekanth chilam - 12-14-2009

Hi,

Is it a evaluation version of QTP 10?

If "YES" then not sure what could be prob.

If "No" then check with the following:

1. In IE 7 > Tools > Internet Options > Security > Uncheck "Enable Protected mode" checkbox & restart the IE.
Now try to execute the code & see.

2. For QTP 10.0 HP provides a patch(QTPWEB_00037) - " Support for Internet Explorer 8"
The following previous hotfix that are also contained in this patch:
  • Fix Browser.RefreshWebSupport for Internet Explorer 7

URL for Patch Download:
http://support.openview.hp.com/downloadAPatch.jsp? patchName=QTPWEB_00037.EXE&prodName=qtp&prodRelease=10.0

Note : HP Passport SignIn login credential are required for downloading.


Now try to execute the code & see.Smile


RE: Unique Browser identification - sunil.kaggarwal - 12-17-2009

Hello Everybody,

We are also facing the same issue. Things are working with QTP 9.2 but giving us error on QTP 10 (irrespective of the fact that we are using trial or licensed, we tried both).

Scenario 1: OS-WinXP SP3, IE6, QTP 9.2 (Code is working fine)
Scenario 2: OS-WinXP SP3, IE7, QTP 9.2 (Code is working fine)

Scenario 3: OS-WinXP SP3, IE7, QTP 10 (Code is giving errors)

I can look for some workaround but personally I want to do the research regarding what wrong we are doing with the code.

I spoke to QTP engineer and he told me that there are some changes in the QTP10 but he is not sure whether this code is part of those changes or not.

Thanks.