How to set default browser window size in Protractor/WebdriverJS

You can also use your config.js to set window size:

// config.js
specs: [
    ...
],
capabilities: {
    browserName: 'chrome',
    chromeOptions: {
        args: ['--window-size=800,600'] // THIS!
    }
}
// ....

If the preferred method:

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

doesn't work for you (for example running Protractor tests in Xvfb), then you can also maximize window this way (protractor.conf.js):

onPrepare: function() {
    setTimeout(function() {
        browser.driver.executeScript(function() {
            return {
                width: window.screen.availWidth,
                height: window.screen.availHeight
            };
        }).then(function(result) {
            browser.driver.manage().window().setSize(result.width, result.height);
        });
    });
},

TypeScript version:

import {Config, browser} from "protractor";

export let config: Config = {
    ...
    onPrepare: () => {
        setTimeout(() => {
            browser.driver.executeScript<[number, number]>(() => {
                return [
                    window.screen.availWidth,
                    window.screen.availHeight
                ];
            }).then((result: [number, number]) => {
                browser.driver.manage().window().setSize(result[0], result[1]);
            });
        });
    }
};

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