Java 全屏操作在selenium webdriver 3.x中不起作用

Java 全屏操作在selenium webdriver 3.x中不起作用,java,selenium,firefox,selenium-webdriver,geckodriver,Java,Selenium,Firefox,Selenium Webdriver,Geckodriver,Firefox版本:52.0.2(32位) 平台:Windows 7 Selenium Webdriver版本:3.4.0(Java绑定) 问题陈述: 尝试在firefox浏览器中执行全屏操作时,会抛出不受支持的命令异常 测试代码: public class GeckoTest { public static void main(String[] args) throws IOException { System.setProperty("webdriver.gecko.

Firefox版本:52.0.2(32位)
平台:Windows 7
Selenium Webdriver版本:3.4.0(Java绑定)
问题陈述: 尝试在firefox浏览器中执行全屏操作时,会抛出不受支持的命令异常

测试代码:

public class GeckoTest {
    public static void main(String[] args) throws IOException {
        System.setProperty("webdriver.gecko.driver","<geckodriver executable>");
        FirefoxBinary binary = new FirefoxBinary(new File("firefox binary"));
        FirefoxOptions options = new FirefoxOptions();
        options.setBinary(binary);
        options.setLogLevel(Level.ALL);
        WebDriver browser = new FirefoxDriver(options);
        browser.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
        browser.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
        browser.get("http://examples.sencha.com/extjs/6.5.0/examples/kitchensink/?classic#form-fieldtypes");
        browser.manage().window().fullscreen();
        WebDriverWait wait = new WebDriverWait(browser,20,3000);
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(".//div[contains(@class,'x-form-spinner x-form-spinner-default x-form-spinner-down x-form-spinner-down-default')]")));
        Actions builder = new Actions(browser);
        builder.doubleClick(browser.findElement(By.xpath(".//div[contains(@class,'x-form-spinner x-form-spinner-default x-form-spinner-down x-form-spinner-down-default')]"))).perform();
        browser.close();
    }
}
公共类壁虎{
公共静态void main(字符串[]args)引发IOException{
System.setProperty(“webdriver.gecko.driver”和“”);
FirefoxBinary=新的FirefoxBinary(新文件(“firefox二进制”);
FirefoxOptions=新的FirefoxOptions();
选项。设置二进制(二进制);
选项.setLogLevel(Level.ALL);
WebDriver browser=新的FirefoxDriver(选项);
browser.manage().timeout().pageLoadTimeout(10,TimeUnit.SECONDS);
browser.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
browser.get(“http://examples.sencha.com/extjs/6.5.0/examples/kitchensink/?classic#form-字段类型);
browser.manage().window().fullscreen();
WebDriverWait wait=新的WebDriverWait(浏览器,203000);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(“../div[contains(@class,'x-form-spinner x-form-spinner-default x-form-spinner-down x-form-spinner-down-default')));
动作生成器=新动作(浏览器);
双击(browser.findElement(By.xpath(“.//div[contains(@class,'x-form-spinner x-form-spinner-default x-form-spinner-down x-form-spinner-down-default'))))))。执行();
browser.close();
}
}

编辑:这似乎是一个已知的问题,当您使用Selenium 3.4.x、geckodriver v0.16.1和Mozilla Firefox 53.0时,将根据此在FF55中修复,正如您所提到的,当我们尝试在Mozilla Firefox浏览器中执行全屏操作时,它抛出不受支持的命令异常为
。然而,在Mozilla Firefox中有一种实现全屏操作的替代方法,它可以通过发送
F11键来实现完美的操作。以下是检查Mozilla Firefox全屏操作的最小代码块:

System.setProperty("webdriver.gecko.driver", "C:\\your_directory\\geckodriver.exe");
WebDriver browser = new FirefoxDriver();
browser.get("http://examples.sencha.com/extjs/6.5.0/examples/kitchensink/?classic#form-fieldtypes");
browser.findElement(By.tagName("body")).sendKeys(Keys.F11);

从Gecko驱动程序FireFox默认情况下,如果得到全屏启动。。。我认为gecko没有实现任何全屏方式。这似乎是一个问题,将在FF55中按照以下方式实现:抱歉,伙计。当你在浏览器上点击F11时,全屏是一种模式。最大化与全屏不同。@请检查我的更新答案,并告诉我它是否适合您。谢谢你。事实上,这是我目前正在使用的解决方法。但是,感谢你的努力,伙计