web-dev-qa-db-ja.com

Selenium 3.6.0&webdriver = new FirefoxDriver(capabilities)-非推奨?

Seleniumの最新バージョンへのアップグレード以降、次のコードは非推奨となったようです:

Selenium 3.6.0 & webdriver = new FirefoxDriver(capabilities) - deprecated? 

完全なコード:

System.setProperty("webdriver.gecko.driver", Base_Page.getConstant(Constant.GECKO_DRIVER_DIRECTORY));
DesiredCapabilities capabilities=DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
webdriver = new FirefoxDriver(capabilities);   //deprecated
8
xGIx

から https://raw.githubusercontent.com/SeleniumHQ/Selenium/master/rb/CHANGES

3.4.1 (2017-06-13)
==================
Firefox:
  * Added new Firefox::Options class that should be used to customize browser
    behavior (command line arguments, profile, preferences, Firefox binary, etc.).
    The instance of options class can be passed to driver initialization using
    :options key. Old way of passing these customization directly to driver
    initialization is deprecated.

3.4.1バージョンから、FirefoxOptionsを使用する必要があります。

11
Davide Patti

次のコード 'FirefoxDriver(capabilities)を、.setCapcability()を使用するfirefoxOptionsに変更しました

FirefoxOptions firefoxOptions = new FirefoxOptions();
    firefoxOptions.setCapability("marionette", true);
    webdriver = new FirefoxDriver(firefoxOptions);
5
xGIx

以下を試してください:

    FirefoxOptions firefoxOptions = new FirefoxOptions();
    firefoxOptions.setCapability("marionette", true);
    WebDriver driver = new FirefoxDriver(firefoxOptions);
1
fahim reza

この行を試すことができます。

FirefoxOptions ffOpt = new FirefoxOptions();
ffOpt.setCapabilities("marionette", true);
WebDriver driver = new FirefoxDriver(ffOpt);
0
SysMurff