Minimizing,Maximizing and Activating browser using QTP


Minimizing,Maximizing and Activating browser using QTP:

Hey folks! have you ever wondered how great it would be has there been a two line code to perform  browser operation like maximize, minimize etc. If you ever whished for the same then your wish has been fulfilled. Dont waste time reading all this non sense comments; Here is the code:

Activate Browser:

Dim hWnd
hWnd=Browser(“micclass:=Browser”).GetROProperty(“hwnd”)
hWnd = Browser(“hwnd:=” & hWnd).Object.hWnd
Window(“hwnd:=” & hWnd).Activate

Minimize Browser:

Dim hWnd

hWnd=Browser(“micclass:=Browser”).GetROProperty(“hwnd”)

hWnd = Browser(“hwnd:=” & hWnd).Object.hWnd

Window(“hwnd:=” & hWnd).Activate

Window(“hwnd:=” & hWnd).Minimize

Maximize Browser:

Dim hWnd

hWnd=Browser(“micclass:=Browser”).GetROProperty(“hwnd”)

hWnd = Browser(“hwnd:=” & hWnd).Object.hWnd

Window(“hwnd:=” & hWnd).Activate

Window(“hwnd:=” & hWnd).Maximize

Cheers! 🙂

Advertisements

7 responses to this post.

  1. Posted by Anonymous on May 24, 2012 at 6:51 pm

    Hi Bibek,

    When I used Maximize Browser code, for a browser that I manually opened, it was working fine.

    However, I tried to use the same code to maximize a pdf document opened in IE through my appplication and I get a General Error for the second line. Can you please assist?

    Here’s the code I used:
    hWnd=Browser(“micclass:=Browser”,”title:=.*”&strCusip&”.*”).GetROProperty(“hwnd”)

    hWnd = Browser(“hwnd:=” & hWnd).Object.hWnd

    Window(“hwnd:=” & hWnd).Activate

    Window(“hwnd:=” & hWnd).Maximize

    Thanks!
    SN

    Reply

  2. Posted by Sachin K on October 6, 2012 at 7:05 am

    Nice 1 bro

    Reply

  3. Posted by Anonymous on March 15, 2013 at 10:41 am

    hai,

    Thanks a lot for the code its working fyn.. can u explain the logic working behind tis ????

    Reply

  4. Posted by GIRISH on March 15, 2013 at 10:42 am

    hai,

    Thanks a lot for the code its working fyn.. can u explain the logic working behind tis ????

    Reply

  5. Posted by Manish Soni on May 13, 2013 at 4:46 am

    use following code, it will never fail..

    Set WshShell = CreateObject(“WScript.Shell”)
    WshShell.SendKeys “%{ }”
    wait(3)
    WshShell.SendKeys ” x”
    Set WshShell=Nothing
    wait(2)

    Reply

  6. Nice one and thanks for giving the code

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: