QTP Descriptive Programs Headline Animator

QTP Descriptive Programs

Tuesday, June 17, 2008

How to Handle Browser window status?

Prerequisites: Not Required
Procedure: Paste the Below Code in QTP window and Click on Run
Code:
Set IE = CreateObject("InternetExplorer.Application") 'Creates an Object to Variable
IE.Visible =True 'Makes Internet Explorer as Visible
IE.Navigate "www.google.com" 'Opens google.com in Internet Explorer
Dim wnd 'Declaring a variable
'hwind = Handling Window
wnd= Browser("Name:= Google.*").GetRoProperty("hwnd") 'Gets the Browser Window Position at Runtime (Maximize or Minimize etc...)
If Window("hwnd:=" &wnd).Maximize = True then 'Checking the Position of the Browser is Maximized or not?
Window("hwnd:=" &wnd).Minimize 'if the Condition is true change the status to Minimized
Else If Window("hwnd:=" &wnd).Minimize = True then 'Checking the Position of the Browser is Minimized or not?
Window("hwnd:=" &wnd).Restore 'if the Condition is true change the status to Restored
Else If Window("hwnd:=" &wnd).Restore = True then 'Checking the Position of the Browser is Restored or not?
Window("hwnd:=" &wnd).Maximize 'if the Condition is true change the status to Maximized
End If
End If
End If

No comments: