Unable to resize or move Google Chrome browser window using WebDriver

3,513 views
Skip to first unread message

Michael Cohen

unread,
Jan 3, 2012, 3:23:06 AM1/3/12
to webdriver
Hi,

I'm trying to use the latest WebDriver (v2.15.dev) to resize and move
a browser window. When I try to execute the following (in Ruby), the
Firefox browser responds to the commands but Google Chrome does not:

driver.manage.window.resize_to 1024, 768
driver.manage.window.move_to 0, 0

WebDriver will give me the follow error message when I use Chrome:

selenium-webdriver-2.15.1.dev/lib/selenium/webdriver/remote/
response.rb:52:in `assert_ok': unknown error, status=405: ["GET",
"HEAD", "DELETE"] (Selenium::WebDriver::Error::WebDriverError)

Looking into the issue some more, it appears that Google Chrome in
fact does not support either the window.moveTo and window.resizeTo
commands [1, 2]. Despite Google's decision for the omission, it does
not hold in the case of testing a web app and making sure it works as
expected when displayed in different window sizes.

Will the Google Chrome driver be updated so that it at least provides
support to actually resize and move the browser window? Or is there
some other way of resizing Google Chrome using WebDriver that I'm
overlooking?

-Mike

[1] http://code.google.com/p/chromium/issues/detail?id=2091
[2]
http://groups.google.com/group/chromium-discuss/browse_thread/thread/273f60896231803a/97c0c23d6d99bd07?lnk=gst&q=resizeTo#97c0c23d6d99bd07

Lukus

unread,
Jan 3, 2012, 5:03:49 PM1/3/12
to webdriver
Michael,

It sounds like you are trying to maximize the window. I ran into the
same issues with javascript resizeTo() and moveTo() as your research
indicates. I believe these commands will only work with a javascript
created window that has no additional tabs.

If maximizing is your goal, that can done with chrome command line
flags (or switches). Here's my Java example, would have to apply
appropriate Ruby syntax:

DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--start-
maximized"));
driver = new ChromeDriver(capabilities);

which on the command line would be equivalent to launching chrome
like : /path/to/chrome.exe --start-maximized

Hope that helps.

Luke

Daniel Wagner-Hall

unread,
Jan 4, 2012, 10:07:10 AM1/4/12
to webd...@googlegroups.com
The ChromeDriver doesn't currently support this API - I've filed a
tracking bug for this:
https://code.google.com/p/selenium/issues/detail?id=3145

The --start-maximised flag is a good workaround for now

> --
> 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.
>

Michael Cohen

unread,
Jan 4, 2012, 1:19:05 PM1/4/12
to webdriver
@Luke: I'm working with a hi-res monitor, so 1024x768 is just one of
many resolutions I'm using to simulate a maximized browser window.
Using the --start-maximized argument is a nice temporary solution, but
it will also require changing the screen's actual resolution.
Therefore, having the ability to actually set the browser's size and
not just maximizing it to the actual screen dimensions is still very
important.

@Daniel: Excellent, thanks a bunch!

-Mike

On Jan 4, 7:07 am, Daniel Wagner-Hall <dawag...@gmail.com> wrote:
> The ChromeDriver doesn't currently support this API - I've filed a
> tracking bug for this:https://code.google.com/p/selenium/issues/detail?id=3145
>
> The --start-maximised flag is a good workaround for now
>
> On 3 January 2012 08:23, Michael Cohen <michael.lee.co...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > I'm trying to use the latest WebDriver (v2.15.dev) to resize and move
> > a browser window. When I try to execute the following (in Ruby), the
> > Firefox browser responds to the commands but Google Chrome does not:
>
> > driver.manage.window.resize_to 1024, 768
> > driver.manage.window.move_to 0, 0
>
> > WebDriver will give me the follow error message when I use Chrome:
>
> > selenium-webdriver-2.15.1.dev/lib/selenium/webdriver/remote/
> > response.rb:52:in `assert_ok': unknown error, status=405: ["GET",
> > "HEAD", "DELETE"] (Selenium::WebDriver::Error::WebDriverError)
>
> > Looking into the issue some more, it appears that Google Chrome in
> > fact does not support either the window.moveTo and window.resizeTo
> > commands [1, 2]. Despite Google's decision for the omission, it does
> > not hold in the case of testing a web app and making sure it works as
> > expected when displayed in different window sizes.
>
> > Will the Google Chrome driver be updated so that it at least provides
> > support to actually resize and move the browser window? Or is there
> > some other way of resizing Google Chrome using WebDriver that I'm
> > overlooking?
>
> > -Mike
>
> > [1]http://code.google.com/p/chromium/issues/detail?id=2091
> > [2]
> >http://groups.google.com/group/chromium-discuss/browse_thread/thread/...

Jari Bakken

unread,
Jan 4, 2012, 4:19:39 PM1/4/12
to webd...@googlegroups.com
On Wed, Jan 4, 2012 at 4:07 PM, Daniel Wagner-Hall <dawa...@gmail.com> wrote:
The ChromeDriver doesn't currently support this API - I've filed a
tracking bug for this:
https://code.google.com/p/selenium/issues/detail?id=3145


This is already tracked in the Chromium tracker:

Michael Cohen

unread,
Jan 4, 2012, 4:38:00 PM1/4/12
to webdriver
@Jari: Is that the correct link? I took a look but the issue is the
following: Crbug's comment text area eats mouse click.

-Mike

On Jan 4, 1:19 pm, Jari Bakken <jari.bak...@gmail.com> wrote:

Daniel Wagner-Hall

unread,
Jan 4, 2012, 4:53:34 PM1/4/12
to webd...@googlegroups.com

Luke Inman-Semerau

unread,
Jan 4, 2012, 4:56:17 PM1/4/12
to webd...@googlegroups.com
Is that a separate issue from http://code.google.com/p/chromium/issues/detail?id=2709
Although that seems RC specific, but i can't tell.

Lukus

unread,
Jan 5, 2012, 3:23:30 AM1/5/12
to webdriver
Well, if anyone can get it done it would be the pull of Selenium, but
last I checked these functions don't work even in pure javascript for
Chrome, and it isn't high on on the developer's priority list. I
looked this up over half a year ago when still working with RC.
WebDriver doesn't have application control either, though Chrome is
working more with webdriver as a standard, but still could be a while
for this.

In the meantime, you'd have to develop something that can resize the
window on the OS side or via a plugin. Also, consider that resolution
can be changed for the OS versus just the window. My experience is
that selenium can not do everything a test suite might need, so my
code contains work-arounds as necessary, like in this case, launching
VMware instances at certain resolutions, or using Java's Robot to send
mouse clicks, and Process to run batch scripts that can get things
done. Just food for thought. Good luck.

James Peterka

unread,
Jul 6, 2014, 5:24:45 PM7/6/14
to webd...@googlegroups.com
I have had to direct my html files to Safari, which handles "resizeto" and "move to".  Neither FireFox nor Google Chrome handles these Javascript commands correctly.

darrell

unread,
Jul 10, 2014, 2:03:57 PM7/10/14
to webd...@googlegroups.com
James,

You should update to a new version of Selenium. This thread is over 2 years old and the known issue was fixed and closed a while ago. If I enter the following it works:

require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome
driver.manage.window.resize_to 800,600
driver.manage.window.move_to 0,0

This will open a chrome browser, resize it to 800 by 600 then move it to the upper left corner of the screen.

Darrell
Reply all
Reply to author
Forward
0 new messages