I am trying to send F11 to ChromeDriver, however it does not respond to it. When I press F11, it turns Chrome into fullscreen mode. When I send F11 through ChromeDriver, it does not. This is the same for any F-key in ChromeDriver. It works fine with FirefoxDriver and IEDriver, just not ChromeDriver. Is there any way I could get ChromeDriver into fullscreen mode ?
Note : Fullscreen mode is different from maximized mode, as it hides all toolbars.
To maximize browser in Selenium, you need to call the maximize() Selenium command to maximize window interface of the driver class. void maximize() – This method is used to maximize the current browser.
When maximized, the title bar etc. of the window is still displayed. In fullscreen mode, the title bar is not displayed.
This can be done with the help of the DesiredCapabilities and ChromeOptions class. We shall create an object of the ChromeOptions class and apply addArguments method on it. Then pass −−incognito as a parameter to that method.
Use the ChromeOptions class An alternate method that can maximize the Chrome window is to use the ChromeOptions class. This method informs the Chrome browser explicitly to launch in maximized mode.
ChromeOptions options = new ChromeOptions();
options.addArguments("--start-fullscreen");
WebDriver driver = new ChromeDriver(options);
if you use RemoteWebDriver:
ChromeOptions options = new ChromeOptions();
options.addArguments("--start-fullscreen");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
Instance = new RemoteWebDriver(new URL(<SeleniumServerURL>), capabilities);
I was able to solve it using kiosk mode, which keeps the browser in full screen
ChromeOptions options = new ChromeOptions();
options.addArguments("--kiosk");
WebDriver driver = new ChromeDriver(options);
The argument is changed:
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
Another option is change the startup script of google-chrome, set start-maximized
as default.
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