Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
112
rated 0 times [  113] [ 1]  / answers: 1 / hits: 87851  / 11 Years ago, sat, november 16, 2013, 12:00:00

For some reason when I run my tests at work the browser is maximized, but when I run them at home it only opens a browser window of about 50% width. This causes some discrepancies with scrolling down, etc., so I'd ideally like to have it open a browser window of the same size on every machine the tests are run on. What's the best way to do this?


(I've found some answers for other languages, but I haven't been able to adapt them to JavaScript)


Adding


browser.executeScript('window.moveTo(0,0);' +
'window.resizeTo(screen.width, screen.height);');

does nothing (apparently window.moveTo and window.resizeTo are not supported by Google Chrome).


More From » angularjs

 Answers
86

You can set the default browser size by running:


var width = 800;
var height = 600;
browser.driver.manage().window().setSize(width, height);

To maximize the browser window, run:


browser.driver.manage().window().maximize();

To set the position, run:


var x = 150;
var y = 100;
browser.driver.manage().window().setPosition(x, y);

If you get an error:



WebDriverError: unknown error: operation is unsupported with remote debugging




Operation not supported when using remote debugging Some WebDriver
commands (e.g. resizing the browser window) require a Chrome extension
to be loaded into the browser. ChromeDriver normally loads this
"automation extension" every time it launches a new Chrome session.


However ChromeDriver can be instructed to connect to an existing
Chrome session instead of launching a new one. This is done using
'debuggerAddress' in the Capabilities (aka ChromeOptions) object.
Since the automation extension is only loaded at startup, there are
some commands that ChromeDriver does not support when working with
existing sessions through remote debugging.


If you see the error "operation not supported when using remote
debugging", try rewriting the test so that it launches a new Chrome
session. This can be done by removing 'debuggerAddress' from the
Capabilities object.



Source: Operation not supported when using remote debugging


[#74246] Friday, November 15, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
havenbilliec

Total Points: 324
Total Questions: 106
Total Answers: 94

Location: Pitcairn Islands
Member since Fri, Oct 15, 2021
3 Years ago
;