The online community for software testing & quality assurance professionals
 
 
Calendar   Today's Topics
Sponsors:
Lost Password?

Home
BetaSoft
Blogs
Jobs
Training
News
Links
Downloads



Testing Tools >> HP Functional Testing / Mercury QuickTest Pro / QTP

Pages: 1 | 2 | >> (show all)
sriniinfy
Member


Reged: 10/04/07
Posts: 54
Maximize the Browser in QTP 9.5
      #484403 - 05/19/08 11:11 PM

I have upgraded QTP from 9.2 to 9.5.

I used the first one to maximize the browser in qtp 9.2. In qtp 9.5 the same steps are not working. So i used second one to maximize.

1) Set obj_WebBr = Description.Create
obj_WebBr ("micclass").value = "Browser"
obj_WebBr ("title").value= "XXXXX"
hWnd = Browser(obj_WebBr).GetROProperty("hwnd")
Window("hwnd:=" & hWnd).Maximize

2)Set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys "% x"

Any help in this regard..

Regards,
Srinivas


Post Extras: Print Post   Remind Me!   Notify Moderator  
subhash_bohra
Advanced Member


Reged: 08/18/06
Posts: 560
Loc: Pune, India
Re: Maximize the Browser in QTP 9.5 [Re: sriniinfy]
      #484510 - 05/20/08 05:31 AM

Moderator of this forum has nice information on his website, Please search on internet as well as on Forum First.

Here is the piece of Code From Tarun's Website and it is provided on forum in past also-

Quote:


'Run a IE Process in Maximized window
Const SHOW_MAXIMIZED = 3 'Activates the window and displays it as a maximized window.
SystemUtil.Run "iexplore.exe", "http://www.knowledgeinbox.com", , , SHOW_MAXIMIZED





--------------------
Thanks

Subhash


"Je pense, donc je suis"


Post Extras: Print Post   Remind Me!   Notify Moderator  
snparikh
Active Member


Reged: 02/05/08
Posts: 878
Loc: Los Angeles, CA, USA
Re: Maximize the Browser in QTP 9.5 [Re: subhash_bohra]
      #489367 - 06/05/08 05:33 PM

Ok... so I have been playing around for almost an hour now trying to maximize the browser (IE7) with a script in QTP 9.5

Searched forum, went through all the related threads and tried different alternatives. But none works.

  • The basic one:
    hwnd=Browser("name:=myBrowser").getROProperty("hwnd")
    Window("hwnd:="&hwnd").Maximize

    This throws the error "The operation cannot be performed ... Window("hwnd:="&hwnd").Maximize"

  • Also tried
    Browser.Object.Width xScreenResolution
    Browser.Object.Height yScreenResolution

    where x and y values of current screen resolution is used. This also throws an error "Operation cannot be performed"

  • The code referenced by Subhash will only open a new browser in maximized state and can not maximize the already open browser.

  • I tried on manually opened browser (opened after QTP was opened) as well as a browser opened by QTP.



If I remember correctly, Windows.Maximize works with IE6/QTP 9.5.

Any tested solutions will be greatly appreciated.

--------------------
-Suchit


Post Extras: Print Post   Remind Me!   Notify Moderator  
atturhari
Newbie


Reged: 10/15/07
Posts: 10
Re: Maximize the Browser in QTP 9.5 [Re: snparikh]
      #489871 - 06/09/08 01:17 AM

Windows().Maximize works in IE6&7/QTP 9.5

Use low level recording and change it to DP.


Post Extras: Print Post   Remind Me!   Notify Moderator  
snparikh
Active Member


Reged: 02/05/08
Posts: 878
Loc: Los Angeles, CA, USA
Re: Maximize the Browser in QTP 9.5 [Re: atturhari]
      #490047 - 06/09/08 10:32 AM

Tried that. Doesn't work for me. Paste a working code if you have.

--------------------
-Suchit


Post Extras: Print Post   Remind Me!   Notify Moderator  
mozza
Newbie


Reged: 06/03/08
Posts: 6
Re: Maximize the Browser in QTP 9.5 [Re: snparikh]
      #490145 - 06/09/08 08:34 PM

This probably is not the help you are looking for but I too struggled to get the browser to resize but this works
hwnd=Browser("title:=JD Edwards EnterpriseOne - Microsoft Internet Explorer").getROProperty("hwnd")
'x="263288"
Window("hwnd:="&hwnd).Maximize

My browser doesn't have a name but it does have the title.
I also found syntax error in:
Window("hwnd:="&hwnd").Maximize - should be
Window("hwnd:="&hwnd).Maximize

Anyway - this has solved my problem to get browser to maximize, so thanks and I am using 9.5


Post Extras: Print Post   Remind Me!   Notify Moderator  
snparikh
Active Member


Reged: 02/05/08
Posts: 878
Loc: Los Angeles, CA, USA
Re: Maximize the Browser in QTP 9.5 [Re: mozza]
      #490417 - 06/10/08 11:18 AM

The problem is not while retrieving hwnd or window handle. I can retrieve that. The problem is while executing .maximize method (error msg stated above). If it works for one person (assuming you are also using IE7), then it should work for me too. I'll look into this matter later on. And the syntax error is just a typo in the post. Thanks for the responses.

--------------------
-Suchit


Post Extras: Print Post   Remind Me!   Notify Moderator  
mazztt
Junior Member


Reged: 05/01/04
Posts: 354
Re: Maximize the Browser in QTP 9.5 [Re: snparikh]
      #490463 - 06/10/08 02:06 PM

Below code is working fine to maximize the window in IE7 with QTP 9.5.

SystemUtil.Run "C:\Program Files\Internet Explorer\iexplore.exe","","C:\Documents and Settings\tester1","open"
Window("Windows Internet Explorer").Activate
Browser("Customize Your Settings").Stop
Window("Windows Internet Explorer").Restore
Window("Windows Internet Explorer").Maximize


Post Extras: Print Post   Remind Me!   Notify Moderator  
snparikh
Active Member


Reged: 02/05/08
Posts: 878
Loc: Los Angeles, CA, USA
Re: Maximize the Browser in QTP 9.5 [Re: mazztt]
      #490476 - 06/10/08 04:05 PM

Ok. Got It!

mazztt, I am using DP so using your script didn't exactly provide me the solution. But coz your version of the recorded script worked, it made me explore a bit more. Thanks for the response!

'-----------
Here's the difference
hwnd1=Browser("name:=myBrowser").getROProperty("hwnd")
'(this is recommended on most of the threads)


hwnd2=Browser("name:=myBrowser").Object.HWND
'(... is what is required for...)


hwnd1 <> hwnd2
'-----------

'set the window object
Set cWindow=Window("hwnd:="&hwnd2)

'then use any of these
cWindow.Maximize
cWindow.Restore
cWindow.Minimize

'----------------

Functions can be found here:
http://www.sqaforums.com/showthreaded.php?Number=490481


Post Extras: Print Post   Remind Me!   Notify Moderator  
mazztt
Junior Member


Reged: 05/01/04
Posts: 354
Re: Maximize the Browser in QTP 9.5 [Re: snparikh]
      #490486 - 06/10/08 05:27 PM

oops, I missed DP..
But I am glad that I could be of your function thought helper.


Post Extras: Print Post   Remind Me!   Notify Moderator  
Tarun LalwaniModerator
Veteran


Reged: 07/21/05
Posts: 15329
Loc: Milwaukee, Wisconsin
Re: Maximize the Browser in QTP 9.5 [Re: mazztt]
      #490530 - 06/10/08 10:54 PM

snparikh, Are you using IE7 with tabs?

I believe on without tabs below should work

hwnd1=Browser("name:=myBrowser").getROProperty("hwnd")
'(this is recommended on most of the threads)

--------------------
Regards,
Tarun
** First ever technical novel - And I thought I knew QTP! **
** Download QTP Unplugged 2nd Edition eBook for FREE **

KnowledgeInbox RSS


Post Extras: Print Post   Remind Me!   Notify Moderator  
snparikh
Active Member


Reged: 02/05/08
Posts: 878
Loc: Los Angeles, CA, USA
Re: Maximize the Browser in QTP 9.5 [Re: Tarun Lalwani]
      #490779 - 06/11/08 10:39 AM

Nopes. Tabs are disabled.

--------------------
-Suchit


Post Extras: Print Post   Remind Me!   Notify Moderator  
ntvru
Junior Member


Reged: 07/12/05
Posts: 10
Re: Maximize the Browser in QTP 9.5 [Re: snparikh]
      #491191 - 06/12/08 10:48 AM

This works for QTP9.5 and IE7:


hwnd1=Browser("Browser").GetROProperty("hwnd")
hwnd2=Browser("Browser").Object.HWND

'set the window object
Set cWindow=Window("hwnd:="&hwnd2)
cWindow.Maximize
'cWindow.Restore
'cWindow.Minimize


Post Extras: Print Post   Remind Me!   Notify Moderator  
snparikh
Active Member


Reged: 02/05/08
Posts: 878
Loc: Los Angeles, CA, USA
Re: Maximize the Browser in QTP 9.5 [Re: ntvru]
      #491192 - 06/12/08 10:53 AM

Ntvru,

What is the purpose of your post?

--------------------
-Suchit


Post Extras: Print Post   Remind Me!   Notify Moderator  
ntvru
Junior Member


Reged: 07/12/05
Posts: 10
Re: Maximize the Browser in QTP 9.5 [Re: snparikh]
      #491194 - 06/12/08 11:17 AM

snparikh: What part of my post is not clear for you?

Post Extras: Print Post   Remind Me!   Notify Moderator  
snparikh
Active Member


Reged: 02/05/08
Posts: 878
Loc: Los Angeles, CA, USA
Re: Maximize the Browser in QTP 9.5 [Re: ntvru]
      #491198 - 06/12/08 11:26 AM

The fact that is says exactly what I did a couple of posts before. It's just redundant.

--------------------
-Suchit


Post Extras: Print Post   Remind Me!   Notify Moderator  
ntvru
Junior Member


Reged: 07/12/05
Posts: 10
Re: Maximize the Browser in QTP 9.5 [Re: snparikh]
      #491202 - 06/12/08 11:31 AM

Sorry, I just confirmed your post with working (tested) script. Don't be angry. Problems at work?
Peace.


Post Extras: Print Post   Remind Me!   Notify Moderator  
TestJM2008
Newbie


Reged: 01/18/08
Posts: 10
Re: Maximize the Browser in QTP 9.5 [Re: ntvru]
      #491363 - 06/13/08 03:16 AM

For maximize the IE,I think maybe we can use the [mode] in the function of systemutil.run
Here is the help file from QTP help.
object.Run file, [params], [dir], [op], [mode]
mode
Optional. An Integer value.
Specifies how the application is displayed when it opens. You can specify one of the modes in the table below.
Default = 1
Mode
Description

0 Hides the window and activates another window.
1 Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. Specify this flag when displaying the window for the first time.
2 Activates the window and displays it as a minimized window.
3 Activates the window and displays it as a maximized window.
4 Displays the window in its most recent size and position. The active window remains active.
5 Activates the window and displays it in its current size and position.
6 Minimizes the specified window and activates the next top-level window in the Z order.
7 Displays the window as a minimized window. The active window remains active.
8 Displays the window in its current state. The active window remains active.
9 Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. Specify this flag when restoring a minimized window.
10 Sets the show-state based on the state of the program that started the application.


I dont know if it will help.
Thanks a lot.

Edited by TestJM2008 (06/13/08 03:17 AM)


Post Extras: Print Post   Remind Me!   Notify Moderator  
snparikh
Active Member


Reged: 02/05/08
Posts: 878
Loc: Los Angeles, CA, USA
Re: Maximize the Browser in QTP 9.5 [Re: TestJM2008]
      #491516 - 06/13/08 11:30 AM

Quote:


....

Specifies how the application is displayed when it opens.

...






TestMJ, your effort is appreciated. But the current discussion is about maximizing/minimizing an already open Web Browser and not how to open a Browser in maximized or minimized state.

--------------------
-Suchit


Post Extras: Print Post   Remind Me!   Notify Moderator  
Tarun LalwaniModerator
Veteran


Reged: 07/21/05
Posts: 15329
Loc: Milwaukee, Wisconsin
Re: Maximize the Browser in QTP 9.5 [Re: snparikh]
      #491578 - 06/14/08 01:44 AM

Can you check what are you getting in

hwnd1=Browser("name:=myBrowser").getROProperty("hwnd")
'(this is recommended on most of the threads)

hwnd2=Browser("name:=myBrowser").Object.HWND
'(... is what is required for...)

hwnd1 <> hwnd2

what are both handles pointing to? Can use Object Spy and see what is the difference between handle values you are getting and which control are they actually for.

I think Browser("name:=myBrowser").getROProperty("hwnd") might not be worked in QTP 9.5 because of it supporting multiple tabs, which means each tab it would consider as a browser and it would be returning you the handle of the Tab and not the top level IE window.

--------------------
Regards,
Tarun
** First ever technical novel - And I thought I knew QTP! **
** Download QTP Unplugged 2nd Edition eBook for FREE **

KnowledgeInbox RSS


Post Extras: Print Post   Remind Me!   Notify Moderator  
snparikh
Active Member


Reged: 02/05/08
Posts: 878
Loc: Los Angeles, CA, USA
Re: Maximize the Browser in QTP 9.5 [Re: Tarun Lalwani]
      #491606 - 06/14/08 12:09 PM

Quote:

...

I think Browser("name:=myBrowser").getROProperty("hwnd") might not be worked in QTP 9.5 because of it supporting multiple tabs, which means each tab it would consider as a browser and it would be returning you the handle of the Tab and not the top level IE window.




I have been wondering about it. Will see and post the results when i get back to work on Monday.

--------------------
-Suchit


Post Extras: Print Post   Remind Me!   Notify Moderator  
snparikh
Active Member


Reged: 02/05/08
Posts: 878
Loc: Los Angeles, CA, USA
Re: Maximize the Browser in QTP 9.5 [Re: Tarun Lalwani]
      #491988 - 06/16/08 04:08 PM

hwnd1=Browser("name:=myBrowser").getROProperty("hwnd")
-> works if you are trying to use browser for object heirarchy.

E.g. Browser("hwnd:="&hwnd1).WebEdit("name:=username").Set username

'-------
But if you need to execute Windows methods on the browser, you will need to use
hwnd2=Browser("name:=myBrowser").Object.HWND

E.g. Window("hwnd:="&hwnd2).Maximize

'The results are based on few experimentations.

Note: For QTP 9.5/IE7, hwnd1 <> hwnd2

--------------------
-Suchit


Post Extras: Print Post   Remind Me!   Notify Moderator  
imhotep
Newbie


Reged: 08/06/07
Posts: 5
Re: Maximize the Browser in QTP 9.5 [Re: snparikh]
      #492344 - 06/17/08 12:21 PM

The code works well in terms of minimizing and maximizing the browser but I've noticed that the memory doesn't reset when QTP minimizes IE. It only works when I do it manually.

Has anyone else come across a solution?


Post Extras: Print Post   Remind Me!   Notify Moderator  
snparikh
Active Member


Reged: 02/05/08
Posts: 878
Loc: Los Angeles, CA, USA
Re: Maximize the Browser in QTP 9.5 [Re: imhotep]
      #492349 - 06/17/08 12:30 PM

What do you mean by memory reset?

--------------------
-Suchit


Post Extras: Print Post   Remind Me!   Notify Moderator  
WarPig
Member


Reged: 07/30/07
Posts: 64
Re: Maximize the Browser in QTP 9.5 [Re: sriniinfy]
      #526694 - 10/23/08 05:36 PM

This Inbuilt QTP method does the job quite nicely:
SystemUtil.Run

Here it is as a function to put in your library file.
Code:
  

Function funcInit_InvokeURL(vURL)

SystemUtil.Run "C:\Program Files\Internet Explorer\iexplore.exe",vURL,"M:\","open","3"

If vURL = "" Then
Reporter.ReportEvent micFail, "ERROR", "Please specify a web address in the form of 'http://server/directory...'"
End If

End Function




The "3" at the end Activates and Maximizes the window.
Just do a search in QTP Help for more modes.

To use the function just put the following lines in your script:
Code:
  

'Open Internet Explorer and point it to a website.
vURL = "http://A website/"
funcInit_InvokeURL(vURL)




Post Extras: Print Post   Remind Me!   Notify Moderator  
snparikh
Active Member


Reged: 02/05/08
Posts: 878
Loc: Los Angeles, CA, USA
Re: Maximize the Browser in QTP 9.5 [Re: WarPig]
      #526703 - 10/23/08 06:49 PM

Yes, and that has been discussed before. The functions are to maximize "already open" browser windows and NOT to "open a browser as a maximized window"

--------------------
-Suchit


Post Extras: Print Post   Remind Me!   Notify Moderator  
Praths
Newbie


Reged: 06/02/09
Posts: 4
Re: Maximize the Browser in QTP 10.0 [Re: snparikh]
      #572261 - 06/02/09 02:08 AM

HI All,

I m trying to maximize application already opened in FireFox using QTP 10.0

I tried both
hwnd1=Browser("name:=myBrowser").getROProperty("hwnd")
'(this is recommended on most of the threads) ---- This gives a runtime error saying "Operation cannot be performed."

hwnd2=Browser("name:=myBrowser").Object.HWND
'(... is what is required for...) --- This also gives a runtime error saying "General run error"

Can anyone help me with this.

Edited by Praths (06/02/09 02:11 AM)


Post Extras: Print Post   Remind Me!   Notify Moderator  
CodeQuixote
Member


Reged: 05/08/07
Posts: 70
Re: Maximize the Browser in QTP 9.5 [Re: Tarun Lalwani]
      #572277 - 06/02/09 03:09 AM

Hi Parikh,

Try this, some times if the brower is already maximized
it will throw an error "operation cannot be performed"
or "General Run Error"

Val=Browser("TestBrowser").WinMenu("SystemMenu").GetItemProperty("Maximize","Enabled")
If Val<>False Then
Browser("TestBrowser").WinMenu("SystemMenu").Select "Maximize"
End If


Post Extras: Print Post   Remind Me!   Notify Moderator  
Praths
Newbie


Reged: 06/02/09
Posts: 4
Re: Maximize the Browser in QTP 10.0 [Re: Praths]
      #594421 - 10/05/09 04:10 AM

Hi All,

I m trying to maximize application already opened in IE8 using QTP 10.0

I tried both
hwnd1=Browser("name:=myBrowser").getROProperty("hwnd")
'(this is recommended on most of the threads) ---- This gives a runtime error saying "Operation cannot be performed."

hwnd2=Browser("name:=myBrowser").Object.HWND
'(... is what is required for...) --- This also gives a runtime error saying "General run error"

When I tried spying the application in QTP 9.2 the title bar was also getting highlighted for browser object, ut in QTP 10.0 it is not happening so.

Can anyone help me with this.


Post Extras: Print Post   Remind Me!   Notify Moderator  
NoUse4aName
Super Member


Reged: 06/13/08
Posts: 1720
Re: Maximize the Browser in QTP 10.0 [Re: Praths]
      #594498 - 10/05/09 09:46 AM

I'd just use keyboard shortcuts, alt + space + x. Should work with any combination.

Set wshShell = CreateObject("WScript.Shell")
wshShell.SendKeys "% x"

Experimented with it for a little bit thinking there might be a need for some delay between keystrokes, but didn't have any problems with it all in the same sendkeys line.

Edited by NoUse4aName (10/05/09 12:54 PM)


Post Extras: Print Post   Remind Me!   Notify Moderator  
satkha
Member


Reged: 07/21/10
Posts: 47
Loc: Kyiv
Re: Maximize the Browser in QTP 10.0 [Re: NoUse4aName]
      #643413 - 09/24/10 07:03 AM

BTW it's much safe to send all the keys separately. From my experience - the browser sometimes may make the wrong action when you do this altogether (f.e. open browser window's menu with Restore, Move, Size, Minimize, Maximize and Close options).

--------------------
All are not hunters that blow the horn


Post Extras: Print Post   Remind Me!   Notify Moderator  
Plattsy
Member


Reged: 04/18/07
Posts: 28
Loc: Sheffield
Re: Maximize the Browser in QTP 9.5 [Re: Tarun Lalwani]
      #651264 - 12/05/10 08:38 PM

I've tried all the solutions on this thread with and without tabbed browsing enabled and none have worked. Running QTP10 with IE8. Anyone care to suggest an alternative. I'm stumped.

Edited by Plattsy (12/05/10 08:40 PM)


Post Extras: Print Post   Remind Me!   Notify Moderator  
Tarun LalwaniModerator
Veteran


Reged: 07/21/05
Posts: 15329
Loc: Milwaukee, Wisconsin
Re: Maximize the Browser in QTP 9.5 [Re: Plattsy]
      #651266 - 12/05/10 09:29 PM

Plattsy,

Refer to the code in below article for IE7

http://knowledgeinbox.com/articles/qtp/general/difference-between-ie6-and-ie7/

The same should work on IE8 as well

--------------------
Regards,
Tarun
** First ever technical novel - And I thought I knew QTP! **
** Download QTP Unplugged 2nd Edition eBook for FREE **

KnowledgeInbox RSS


Post Extras: Print Post   Remind Me!   Notify Moderator  
Plattsy
Member


Reged: 04/18/07
Posts: 28
Loc: Sheffield
Re: Maximize the Browser in QTP 9.5 [Re: Tarun Lalwani]
      #651403 - 12/06/10 02:09 PM

QTP10 and IE8 update.

For some reason this code wasn't working yesterday but is working today. No idea why but there you go.
SystemUtil.Run "C:\Program Files\Internet Explorer\iexplore.exe",vURL,"M:\","open","3"

Taruns code for maximising an already open browser in the link below works too. Thanks Tarun.

Refer to the code in below article for IE7
http://knowledgeinbox.com/articles/qtp/general/difference-between-ie6-and-ie7/
The same should work on IE8 as well

Also another option for that belt and braces approach is to set the IE properties too.
Right click the IE icon in your task bar.
Click Properties.
Select Maxmized from the Run dropdown and Apply.
This may require a restart of your machine as it wouldn't work yesterday but works fine today.

Hope this helps.


Post Extras: Print Post   Remind Me!   Notify Moderator  
Tarun LalwaniModerator
Veteran


Reged: 07/21/05
Posts: 15329
Loc: Milwaukee, Wisconsin
Re: Maximize the Browser in QTP 9.5 [Re: Plattsy]
      #651423 - 12/06/10 08:28 PM

You should change

SystemUtil.Run "C:\Program Files\Internet Explorer\iexplore.exe",vURL,"M:\","open","3"


to

SystemUtil.Run "iexplore.exe",vURL

No need to have other recorded values

--------------------
Regards,
Tarun
** First ever technical novel - And I thought I knew QTP! **
** Download QTP Unplugged 2nd Edition eBook for FREE **

KnowledgeInbox RSS


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1 | 2 | >> (show all)



Extra information
0 registered and 86 anonymous users are browsing this forum.

Moderator:  IanFraser, Rajkumar_Rajangam, thorwath, TReddy, AJ, Tarun Lalwani, mwsrosso 

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 15091

Rate this topic

Jump to

Contact Us | Privacy statement SQAForums

Powered by UBB.threads™ 6.5.5