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?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With