Unable to Maximize Chrome Window

8,024 views
Skip to first unread message

Ranjith Manne

unread,
Feb 24, 2012, 2:15:21 AM2/24/12
to webd...@googlegroups.com
Hi All,

I was unable to maximize the chrome window,I tried it in 2-ways to maximize the browser.

Method-1

String URL ="http://www.google.co.in";
ChromeDriver driver = new ChromeDriver(cds);
driver.get(URL);
Selenium sel = new WebDriverBackedSelenium(driver,URL);
sel.windowMaximize();


Method-2

public void maximise() {
 Toolkit toolkit = Toolkit.getDefaultToolkit();

Dimension screenResolution = new Dimension((int)       

        toolkit.getScreenSize().getWidth(), (int)
        toolkit.getScreenSize().getHeight());

         driver.manage().window().setSize(screenResolution);

}


Note: By using above 2 logics i was able to maximize the IE and Firefox browsers.


Thanks,
Ranjith.

Krishnan Mahadevan

unread,
Feb 24, 2012, 2:23:08 AM2/24/12
to webd...@googlegroups.com
Refer here to understand how to go about making use of chrome browser flags for maximizing the window.

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 "webdriver" group.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.

shiva hosur

unread,
Feb 24, 2012, 2:25:35 AM2/24/12
to webd...@googlegroups.com
Hi Ranjith,

Try using the below method

public String maximizeWindow() {
return "if (window.screen) {window.moveTo(0, 0);window.resizeTo(window.screen.availWidth,window.screen.availHeight)}";
}

Regards
Shivashankar

Mark Collin

unread,
Feb 24, 2012, 4:03:24 AM2/24/12
to webd...@googlegroups.com

I believe that Google Chrome currently does not support window resizing.

--

You received this message because you are subscribed to the Google Groups "webdriver" group.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.


-- This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error please notify postm...@ardescosolutions.com

Krishnan Mahadevan

unread,
Feb 24, 2012, 4:10:58 AM2/24/12
to webd...@googlegroups.com
Mark,
Not even with the command line flag ?

Thanks & Regards
Krishnan Mahadevan

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



Mark Collin

unread,
Feb 24, 2012, 4:29:43 AM2/24/12
to webd...@googlegroups.com

Well the command line flag will start it maximised, but you still can’t resize the windows when it is running as far as I’m aware (They may have added something in recently I don’t know about).

Krishnan Mahadevan

unread,
Feb 24, 2012, 4:32:35 AM2/24/12
to webd...@googlegroups.com
Hmm.. ok.. I was more concerned on starting up the browser in maximized mode Mark :) Am glad that still remains as is.

Thanks & Regards
Krishnan Mahadevan

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


Ranjith Manne

unread,
Feb 24, 2012, 4:33:03 AM2/24/12
to webd...@googlegroups.com
Hi All,

Thanks for all your suggestions.
Now i am able to maximize the chrome window by using the following code:


System.setProperty("webdriver.chrome.driver", "D:\\Ranjith\\Softwares\\chromedriver_win_18.0.1022.0\\chromedriver.exe");
                   
              DesiredCapabilities capabilities = DesiredCapabilities.chrome();
              capabilities.setCapability("chrome.switches", Arrays.asList("--start-maximized"));
              WebDriver driver1 = new ChromeDriver(capabilities);



@ Krishnan: I have implented this using the link which you sent to me.
i.e http://code.google.com/p/selenium/wiki/ChromeDriver#Advanced_Usage
Thanks Krishnan.

Warm Regards,
Ranjith.

Pavithra

unread,
May 17, 2012, 9:37:12 AM5/17/12
to webd...@googlegroups.com
Above doesn't work for MAC. Any idea how to maximize chrome on MAC ?

Moises Siles

unread,
May 17, 2012, 9:58:55 AM5/17/12
to webd...@googlegroups.com
I don't remember if I already try  this but could you take a look at the following code

                        ChromeOptions options = new ChromeOptions();
                        options.AddArguments("start-maximized");
                        webDriver = new ChromeDriver(path, options);

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To view this discussion on the web visit https://groups.google.com/d/msg/webdriver/-/FbEFAejzYrEJ.

darrell

unread,
May 18, 2012, 9:34:30 AM5/18/12
to webdriver
I haven't tried running this on a Mac but try:

Point targetPosition = new Point(0, 0);
driver.manage().window().setPosition(targetPosition);

String w = "return screen.availWidth";
String h = "return screen.availHeight";
int width = ((Long)driver.executeScript(w)).intValue();
int height = ((Long)driver.executeScript(h)).intValue();
Dimension targetSize = new Dimension(width, height);
driver.manage().window().setSize(targetSize);

Unlike Windows there is not maximize window feature. The green +
button on a Mac window is different from the maximize window button on
Windows. To re-size the window to the full screen size I position the
existing window to (0, 0), get the window width and height via
Javascript then set the size of the window to be the window width and
height.

Darrell

On May 17, 9:58 am, Moises Siles <moises.si...@gmail.com> wrote:
> I don't remember if I already try  this but could you take a look at the
> following code
>
>                         ChromeOptions options = new ChromeOptions();
>                         options.AddArguments("start-maximized");
>                         webDriver = new ChromeDriver(path, options);
>
>
>
>
>
>
>
> On Thu, May 17, 2012 at 7:37 AM, Pavithra <pavi...@gmail.com> wrote:
> > Above doesn't work for MAC. Any idea how to maximize chrome on MAC ?
>
> > On Friday, February 24, 2012 3:03:03 PM UTC+5:30, RanjithManne wrote:
>
> >> Hi All,
>
> >> Thanks for all your suggestions.
> >> Now i am able to maximize the chrome window by using the following code:
>
> >> System.setProperty("webdriver.**chrome.driver", "D:\\Ranjith\\Softwares\\
> >> **chromedriver_win_18.0.1022.0\\**chromedriver.exe");
>
> >>             *  DesiredCapabilities capabilities =
> >> DesiredCapabilities.chrome();
> >>               capabilities.setCapability("chrome.switches",
> >> Arrays.asList("--start-maximized"));
> >>               WebDriver driver1 = new ChromeDriver(capabilities);*
>
> >> @ Krishnan: I have implented this using the link which you sent to me.
> >> i.ehttp://code.google.com/p/**selenium/wiki/ChromeDriver#**Advanced_Usage

Phoenix Bertone

unread,
Jun 2, 2016, 12:35:35 AM6/2/16
to webdriver


On Friday, February 24, 2012 at 2:15:21 AM UTC-5, Ranjith Manne wrote:
um,.. you do not need code you can just hit the Maximize button
Reply all
Reply to author
Forward
0 new messages