硒和壁虎驱动程序-打开Firefox全屏

时间:2018-12-07 15:49:51

标签: java selenium firefox

我正在尝试将Selenium(v.3.4.0)与“ gecko”网络驱动程序(我相信为.17)一起以全屏(未最大化)打开较旧版本的Firefox(52.9.0 ESR)。但是,即使在浏览了该网站上的某些问题以及进行其他研究之后,我仍然无法全屏打开Firefox。我的代码很简单:

    public static void main(String[] args) throws InterruptedException {
    System.setProperty("webdriver.gecko.driver", "/usr/bin/geckodriver");
    String user = args[0];
    String pass = args[1];

    FirefoxOptions options = new FirefoxOptions();

    // options.addArguments("--start-fullscreen");
    // options.addArguments("--start-maximized");
    // options.addArguments("--disable-infobars");
    ProfilesIni profile = new ProfilesIni();
    FirefoxProfile ffprofile = profile.getProfile("SELENIUM");
    FirefoxDriver driver = new FirefoxDriver(ffprofile);

    driver.get(BASE_URL);
    driver.findElement(By.name("user")).sendKeys(user);
    driver.findElement(By.name("pass")).sendKeys(pass);
    driver.findElement(By.id("login")).click();

}

我尝试了以下方法:

  • 使用自定义配置文件并加载两个不同的扩展名(“自动全屏”和“ MPT全屏”)。
  • 使用driver.getKeyboard().sendKeys(Keys.F11);(引发Exception in thread "main" org.openqa.selenium.UnsupportedCommandException: sendKeysToActiveElement
  • 寻找要传递给浏览器的命令行参数。

我可以通过简单地设置一个选项就可以在Chromium中工作,但是使用Firefox并没有成功。我如何使它与该浏览器一起使用?我使用的是旧版本的Firefox,因为它运行在Rasperry PI上,并且似乎是设备支持的最新版本。

谢谢。

编辑:     driver.manage().window().fullscreen()的输出:

INFO: Detected dialect: W3C
Dec 11, 2018 9:07:29 AM org.openqa.selenium.remote.ErrorCodes toStatus
INFO: HTTP Status: '404' -> incorrect JSON status mapping for 'unknown error' (500 expected)
Exception in thread "main" org.openqa.selenium.WebDriverException: fullscreenWindow
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'xxx', ip: 'xxx', os.name: 'Linux', os.arch: 'arm', os.version: '4.14.79-v7+', java.version: '1.8.0_65'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{moz:profile=/tmp/rust_mozprofile.GRnhrulj1j6l, rotatable=false, timeouts={implicit=0.0, page load=300000.0, script=30000.0}, pageLoadStrategy=normal, platform=ANY, specificationLevel=0.0, moz:accessibilityChecks=false, acceptInsecureCerts=false, browserVersion=52.9.0, platformVersion=4.14.79-v7+, moz:processID=1076.0, browserName=firefox, javascriptEnabled=true, platformName=linux}]
Session ID: 6633ed83-9a19-4e5c-9229-5fadef8a83ce
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:150)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:115)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:45)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:694)
    at org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteWindow.fullscreen(RemoteWebDriver.java:929)
    at com.midamcorp.kblogin.Entry.main(Entry.java:31)

0 个答案:

没有答案