I want to start the chromedriver my second screen, but in a maximized window. Currently, I'm doing this after already the driver has already been initialized:
driver.Manage().Window.Position = Screen.AllScreens[myDisplayNumber].Bounds.Location;
driver.Manage().Window.Maximize();
But while I'm fixing the error mentioned here, I am now using the ChromeOptions to set the window maximized. To start the browser on my other screen, I tried the '--window-position'-argument. The thing is, it just doesn't work in combination with the '--start-maximized' argument. The browser starts on the specified window position on my second screen, but the window is not maximized. If I delete the '--window-position'-argument, then the browser starts maximized on my primary screen. One interesting thing is, if I replace '--start-maximized' with '--start-fullscreen', it works. I get the fullscreen-mode on my second screen. Why is this not working with '--start-maximized'?
This is how I specify the options and start the driver :
var options = new ChromeOptions();
options.PageLoadStrategy = PageLoadStrategy.None;
var windowPosition = $"--window-position=1600,-500";
options.AddArguments(
windowPosition,
"--start-maximized",
//"--start-fullscreen",
"--enable-automation",
"--no-sandbox",
"--disable-dev-shm-usage",
"--disable-browser-side-navigation",
"--disable-gpu"
);
options.AddAdditionalOption(CapabilityType.AcceptInsecureCertificates, true);
options.AddUserProfilePreference("download.default_directory", Directory.GetCurrentDirectory());
var driverService = ChromeDriverService.CreateDefaultService();
return new ChromeDriver(driverService, options, TimeSpan.FromSeconds(30));