Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ChromeDriver in Fullscreen Mode

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.

like image 227
sworded Avatar asked Feb 28 '12 17:02

sworded


People also ask

How do I make Selenium full screen?

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.

What is the difference between maximize and full screen in Selenium?

When maximized, the title bar etc. of the window is still displayed. In fullscreen mode, the title bar is not displayed.

How do I open ChromeDriver in incognito mode?

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.

Which of the following option opens Chrome browser in maximized state?

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.


3 Answers

    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);
like image 99
Boris Frenkel Avatar answered Nov 17 '22 04:11

Boris Frenkel


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);
like image 43
sworded Avatar answered Nov 17 '22 05:11

sworded


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.

like image 39
Xiaoming Avatar answered Nov 17 '22 04:11

Xiaoming