2017-10-10 59 views
1

由于升级到硒的最新版本,下面的代码似乎被弃用:Selenium 3.6.0&webdriver =新的FirefoxDriver(功能) - 弃用?

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 

回答

4

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

改变了下面的代码'FirefoxDriver(capabilities)firefoxOptions它采用.setCapcability()

FirefoxOptions firefoxOptions = new FirefoxOptions(); 
    firefoxOptions.setCapability("marionette", true); 
    webdriver = new FirefoxDriver(firefoxOptions); 
+2

请加你的答案是如何解决问题的一些解释,代码示例帮助,但解释帮助别人理解为什么它的工作原理。 –

相关问题