2017-10-10 54 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

請加你的答案是如何解決問題的一些解釋,代碼示例幫助,但解釋幫助別人理解爲什麼它的工作原理。 –

相關問題