RemoteWebDriver Chrome - start maximized

Pavel Janicek picture Pavel Janicek · Mar 30, 2012 · Viewed 19.4k times · Source

I need chrome to start maximized when running via the selenium grid.

This is how do I initialize it now:

Selenium selenium = new DefaultSelenium("localhost", 4444, "*googlechrome", "http://www.google.com");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);

Chrome does come up, but not maximized. In usual ChromeDriver I did it like this

ChromeOptions options = new ChromeOptions();
options.addArguments("--start-maximized");

But I dont know how to pass it to RemoteWebDriver. Can anybody help?

Answer

Petr Janeček picture Petr Janeček · Mar 30, 2012
ChromeOptions options = new ChromeOptions();
options.addArguments("--start-maximized");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);

That's how I do it.