11

Since upgrading to the latest version of Selenium the following code seems to be deprecated:

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

Full code:

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
MD. Khairul Basar
  • 4,976
  • 14
  • 41
  • 59
xGIx
  • 509
  • 3
  • 7
  • 26

4 Answers4

13

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

From the 3.4.1 version the FirefoxOptions should be used.

Davide Patti
  • 3,391
  • 2
  • 18
  • 20
7

Changed the following code 'FirefoxDriver(capabilities) to firefoxOptions which uses .setCapcability()

FirefoxOptions firefoxOptions = new FirefoxOptions();
    firefoxOptions.setCapability("marionette", true);
    webdriver = new FirefoxDriver(firefoxOptions);
iamsankalp89
  • 4,607
  • 2
  • 15
  • 36
xGIx
  • 509
  • 3
  • 7
  • 26
  • 3
    Please add some explanation of how your answer solves the problem, code samples help, but explanation helps others understand why it works. – Nigel Ren Oct 10 '17 at 18:01
1

You can try this line;

FirefoxOptions ffOpt = new FirefoxOptions();
ffOpt.setCapabilities("marionette", true);
WebDriver driver = new FirefoxDriver(ffOpt);
ghazouan badr
  • 472
  • 5
  • 16
SysMurff
  • 126
  • 2
  • 14
1

Try following:

    FirefoxOptions firefoxOptions = new FirefoxOptions();
    firefoxOptions.setCapability("marionette", true);
    WebDriver driver = new FirefoxDriver(firefoxOptions);
Anj Raju
  • 606
  • 7
  • 7