Frage

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.

War es hilfreich?

Lösung

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);

Andere Tipps

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.

    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);
driver.manage().window().fullscreen();

Use --start-fullscreen argument to Specify the browser should start in fullscreen mode, like if the user had pressed F11 right after startup.

ChromeOptions options = new ChromeOptions();
options.addArguments("--start-fullscreen");
WebDriver driver = new ChromeDriver(options);

You can change the behavior as you prefer by providing arguments to ChromeOptions.

Following link gives you in detail view of arguments and their behaviour. Hope it helps.

https://peter.sh/experiments/chromium-command-line-switches/#start-fullscreen

In my case, i fix the differences between selenium webdriver coordinates and screen absolute coordinates (root cause: chrome tab, header and address field size are ignored by selenium .getcoordinate mechanism) by this way:

String shortcutGoToFullScreen = Keys.chord(Keys.F11);
WebDriver.findElement(By.tagName("body")).sendKeys(shortcutGoToFullScreen);

Only one problem, that this fullscreen mode became non full after any page code updates. So, it should be used carefully )

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top