chromedriver full screen doesn't work on Linux

chromedriver全屏幕不工作的Linux

问题 (Question)

I am trying to start Chrome browser in full screen mode (similar to using F11) on Ubuntu 12.04. I am using the following code, but this doesn't see to work:

       if (browser.equalsIgnoreCase("chrome")) {
            //Set full screen mode (similar to F11)
            ChromeOptions options = new ChromeOptions();
            options.addArguments("start-fullscreen");
            //Create a new Chrome Driver
            System.setProperty("webdriver.chrome.driver","./lib/chromedriver");
            this.driver = new ChromeDriver(options);
        }

I am using Chrome version 34 with WebDriver version 2.41. Any suggestions?

我想在全屏幕模式启动Chrome浏览器(类似于使用F11)对Ubuntu 12.04。我用下面的代码,但是这不见工作:

       if (browser.equalsIgnoreCase("chrome")) {
            //Set full screen mode (similar to F11)
            ChromeOptions options = new ChromeOptions();
            options.addArguments("start-fullscreen");
            //Create a new Chrome Driver
            System.setProperty("webdriver.chrome.driver","./lib/chromedriver");
            this.driver = new ChromeDriver(options);
        }

我使用的浏览器34版与2.41版webdriver。有什么建议吗?

最佳答案 (Best Answer)

Linux Mint 16, Chrome version 34.0.1847.132, Selenium 2.41. Full screen mode works fine. Try to use:

driver.manage().window().maximize();

to maximize browser window.

Edited.

Also you can try to run chrome in kiosk mode:

ChromeOptions options = new ChromeOptions();
options.addArguments("--kiosk");
driver = new ChromeDriver(options);

This works fine in Linux with Chrome 34.

Or try to press F11 like:

driver.findElement(By.tagName("html")).sendKeys(Keys.F11);

But for me it works fine only in Firefox.

Linux Mint 16,铬版34.0.1847.132,硒2.41。全屏幕模式下工作的很好。尝试:

driver.manage().window().maximize();

在浏览器窗口最大化。

编辑。

你也可以尝试运行在kiosk模式铬:

ChromeOptions options = new ChromeOptions();
options.addArguments("--kiosk");
driver = new ChromeDriver(options);

本工程的罚款铬34 Linux。

或者试着按F11一样:

driver.findElement(By.tagName("html")).sendKeys(Keys.F11);

但对我来说,它只能在Firefox。

答案 (Answer) 2

If you're trying to send F11 to the browser, you can probably do it this way:

driver.FindElement(By.TagName("html")).SendKeys(Keys.F11);

如果你想发送F11浏览器,你可以这样做:

driver.FindElement(By.TagName("html")).SendKeys(Keys.F11);

本文翻译自StackoverFlow,英语好的童鞋可直接参考原文:http://stackoverflow.com/questions/23434875