Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RemoteWebDriver Chrome - start maximized

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?

like image 600
Pavel Janicek Avatar asked Mar 30 '12 11:03

Pavel Janicek


2 Answers

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.

like image 165
Petr Janeček Avatar answered Sep 28 '22 04:09

Petr Janeček


The above solutions did not work for me but this did

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

DesiredCapabilities capabilities = options.ToCapabilities() as DesiredCapabilities;
capabilities?.SetCapability(CapabilityType.BrowserName, "chrome");

Driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capabilities);

Hope this helps someone.

like image 30
Brian Mitchell Avatar answered Sep 28 '22 04:09

Brian Mitchell