Micro Focus QTP (UFT) Forums

Full Version: Maximize and Close a Browser
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
Browser("micclass:=Browser).Close
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



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
[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]