Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Maximize and Close a Browser
#1
Solved: 11 Years, 3 Months, 4 Weeks ago
I have been trying the code below to Maximize and then close a Browser. But it is not working on line 4 , line 6 works

Code:
Browser("Browser").Page("Page").WebTable("Fax Status").Highlight(0)
Browser("Browser").Page("Page").Sync
hWnd = Browser("Browser").GetROProperty("hwnd")
Window("hwnd:=" & hWnd).Maximize
Window("hwnd:=" & hWnd).Close

I also tried:
Code:
hWnd = Browser("Browser").GetROProperty("hwnd")
title= Browser("micClass:=Browser", "hwnd:=" & hWnd).GetROProperty("title")
Window("title:=" & title).Maximize

But more than one Browser is open (i have 2 browsers open, only 1 called Browser)

What is wrong with my logic? I see this code all over the web.

thx
Reply
#2
Solved: 11 Years, 3 Months, 4 Weeks ago
Browser("micclass:=Browser).Close
Reply
#3
Solved: 11 Years, 3 Months, 4 Weeks ago
This is the best way of closing Browser

Code:
Browser("Browser").Close


For Maximize
Code:
hWnd=Browser("Browser").GetROProperty("hwnd")
hWnd = Browser("hwnd:=" & hWnd).Object.hWnd
Window("hwnd:=" & hWnd).Activate
Window("hwnd:=" & hWnd).Maximize

Note: Its best practice to maximize window,
First get the handle of browser, then Activate then Maximize.

Regards,
Munna Sarfraz



Reply
#4
Solved: 11 Years, 3 Months, 4 Weeks ago
thx Vinod123 and Munna

Is it ok to use:

Code:
Window("hwnd:=" & hWnd).Close

I am thinking that Browser("Browser").Close may close the wrong browser window?

thx guys
Reply
#5
Solved: 11 Years, 3 Months, 4 Weeks ago
[quote pid='19664' dateline='1326799441']
Code:
I had a General Run error when trying to get
hWnd = Browser("hwnd:=" & hWnd).Object.hWnd

In another forum I came across this code: (automationrepository)
and it worked without getting to the .Object.hWnd
Hope it might help someone.
hwnd = Browser("CreationTime:=0"").GetROProperty("top_level_hwnd")
Window("hwnd:=" & hwnd).Maximize


Regards,
Mike




[/quote]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Close popup ad windows dustwynn 1 2,961 10-25-2016, 05:57 PM
Last Post: Ankur
  [UFT] Close opened folder robertosalemi 1 3,353 02-10-2016, 07:06 PM
Last Post: robertosalemi
  Close browser code not working akilamurugesh 1 4,640 08-26-2014, 03:21 PM
Last Post: vinod123
  Close on Exit Issue in QTP 11.0 EGBELL 1 3,209 02-02-2014, 03:39 PM
Last Post: EGBELL
  Unable to close new tab pradeep singh 3 8,974 03-05-2013, 09:43 AM
Last Post: pradeep singh

Forum Jump:


Users browsing this thread: 1 Guest(s)