自升级到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
答案 0 :(得分:11)
来自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。
答案 1 :(得分:5)
将以下代码' FirefoxDriver(capabilities)
更改为使用firefoxOptions
的{{1}}
.setCapcability()
答案 2 :(得分:1)
尝试以下操作:
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setCapability("marionette", true);
WebDriver driver = new FirefoxDriver(firefoxOptions);
答案 3 :(得分:0)
你可以尝试这一行;
FirefoxOptions ffOpt = FirefoxOptions();
ffOpt.setCapabilities("marionette", true);
WebDriver driver = FirefoxDriver(ffOpt);