web-dev-qa-db-fra.com

Selenium 3.6.0 & webdriver = new FirefoxDriver (possibilités) - obsolète?

Depuis la mise à niveau vers la dernière version de Selenium, le code suivant semble être obsolète:

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

Code complet:

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
6
xGIx

De 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.

À partir de la version 3.4.1, FirefoxOptions devrait être utilisé.

10
Davide Patti

Le code suivant 'FirefoxDriver(capabilities) a été remplacé par firefoxOptions qui utilise .setCapcability()

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

Essayez de suivre:

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

Vous pouvez essayer cette ligne;

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