Maximize Browser in Selenium Webdriver

3,160 views
Skip to first unread message

sanam

unread,
Mar 15, 2012, 1:45:55 AM3/15/12
to seleniu...@googlegroups.com
Hi,

      To maximize the browser in Selenium Webdriver, there seems to be no direct way. I looked through many forums and they all suggested to execute js code.

Is there any better way to achieve this?

Thanks,
Sanam

selenium_freak

unread,
Mar 15, 2012, 2:29:03 AM3/15/12
to Selenium Users
if java .
driver.manage().window().setsize is your method .

Krishnan Mahadevan

unread,
Mar 15, 2012, 3:35:17 AM3/15/12
to seleniu...@googlegroups.com
I dont think that method is implemented for all browsers. The last I heard on that, was that it was an experimental feature that was being implemented only for firefox. I might be wrong too.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


sanam

unread,
Mar 15, 2012, 3:58:31 AM3/15/12
to seleniu...@googlegroups.com
Hi 

@ Krishnan  Based on your discussion in  different post thread i tried the command line argument for starting Chrome in maximized code..However it throws an exception

@Selenium_freak - I have used that method currently, i observed that if the window is completely minimized then it works fine, however if the window is resized say manually and made smaller, then the above code doesnt maximize it to the fullest but just changes the dimentions.
The code is as below:

                      driver.get("http://www.google.com");
Toolkit toolkit = Toolkit.getDefaultToolkit();
   Dimension screenResolution = new Dimension((int)
toolkit.getScreenSize().getWidth(), (int)
toolkit.getScreenSize().getHeight());
driver.manage().window().setSize(screenResolution);

Thanks,
Sanam
On Thursday, March 15, 2012 1:05:17 PM UTC+5:30, Krishnan wrote:
I dont think that method is implemented for all browsers. The last I heard on that, was that it was an experimental feature that was being implemented only for firefox. I might be wrong too.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"


On Thu, Mar 15, 2012 at 11:59 AM, selenium_freak <selen...@gmail.com> wrote:
if java .
driver.manage().window().setsize is your method .

On Mar 15, 10:45 am, sanam <sanam.ch...@qualitiasoft.com> wrote:
> Hi,
>
>       To maximize the browser in Selenium Webdriver, there seems to be no
> direct way. I looked through many forums and they all suggested to execute
> js code.
>
> Is there any better way to achieve this?
>
> Thanks,
> Sanam

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.

sanam

unread,
Mar 15, 2012, 4:01:34 AM3/15/12
to seleniu...@googlegroups.com
Hi

another thing i forgot to mention that  driver.manage().window().setsize  only works for ff and not for ie

sanam

unread,
Mar 15, 2012, 4:04:18 AM3/15/12
to seleniu...@googlegroups.com
@krishnan..

The command line arguments for Chrome is working fine. It was a silly mistake from my end. 

Thanks,
Sanam

selenium_freak

unread,
Mar 15, 2012, 4:27:23 AM3/15/12
to Selenium Users
it works for ie8 not sure for other versions.
> >> On Thu, Mar 15, 2012 at 11:59 AM, selenium_freak <selenium...@gmail.com>wrote:
>
> >>> if java .
> >>> driver.manage().window().setsize is your method .
>
> >>> On Mar 15, 10:45 am, sanam <sanam.ch...@qualitiasoft.com> wrote:
> >>> > Hi,
>
> >>> >       To maximize the browser in Selenium Webdriver, there seems to be
> >>> no
> >>> > direct way. I looked through many forums and they all suggested to
> >>> execute
> >>> > js code.
>
> >>> > Is there any better way to achieve this?
>
> >>> > Thanks,
> >>> > Sanam
>
> >>> --
> >>> You received this message because you are subscribed to the Google
> >>> Groups "Selenium Users" group.
> >>> To post to this group, send email to seleniu...@googlegroups.com.
> >>> To unsubscribe from this group, send email to
> >>> selenium-user...@googlegroups.com.
Message has been deleted

sanam

unread,
May 9, 2012, 3:10:09 AM5/9/12
to seleniu...@googlegroups.com
Hi,

       To maximize browser, a new api is introduced in selenium webdriver 2.21. 

       driver.manage().window().maximize().

Hope this helps.
Thanks,
Sanam
> >>> To post to this group, send email to selenium-users@googlegroups.com.
> >>> To unsubscribe from this group, send email to

Gulshan Saini

unread,
May 9, 2012, 11:26:04 AM5/9/12
to seleniu...@googlegroups.com
You should look at this post http://www.selenium-testing.com/2012/04/webdriver-maximize-browser-window-in.html
In selenium version 2.21 maximize() command has been added.

       driver.manage().window().maximize().

Note: This works only in Firefox and IE

Thanks
Gulshan
Reply all
Reply to author
Forward
0 new messages