Saturday, June 30, 2012

How to verify a Browser Window is minimized

The bad part is  QTP does not support retrieving RO Properties of a browser. If it has supported, then we would have use a method like Browser("Browser Name").GetROProperty("minimized")




















But we can use Extern to use some of the methods from Windows user32.dll
Following are the two ways to verify the window minimized.
Extern.Declare micHwnd, "FindWindow", "user32.dll","FindWindowA", micString,micString 'this method returns a handle
Extern.Declare micLong,"GetWindowMinimizeState", "user32.dll" ,"IsZoomed",micLong 'IsZoomed meaning IsMaximized
hwnd=extern.FindWindow(NULL,"Links - Windows Internet Explorer")
print Extern.GetWindowMinimizeState(hwnd) 'Similar way


Const GA_ROOT = 2
'Declare Function GetAncestor Lib "user32.dll" (ByVal hwnd As Long, ByVal gaFlags As Long) As Long Extern.Declare micLong, "GetMainWindow", "user32" ,"GetAncestor",micLong, micLong
hwnd = browser("name:=Links.*").GetROProperty("hwnd") 'this returns the handle of the Browser Tab hwnd = Extern.GetMainWindow(hwnd , GA_ROOT) 'This returns the handle of the browser(which means handle of the browser)
msgbox Window("hwnd:=" & hwnd ).GetROProperty("minimized")

No comments: