2016-08-17 94 views
1

如何使用FF 48便攜式木偶驅動程序? 我知道它是如何工作與Firefox安裝48:Selenium - 使用便攜式Firefox 48與木偶驅動程序

String marionetteDriverLocation = getClass().getClassLoader().getResource("[PATH_TO_GECKODRIVER]/wires.exe").getPath(); 
System.setProperty("webdriver.gecko.driver", marionetteDriverLocation); 
WebDriver driver = new MarionetteDriver(createDefaultCapabilitiesFirefox()); 

和Firefox便攜高達46:

FirefoxBinary binary = new FirefoxBinary(new File(firefoxPortablePath)); 
WebDriver driver = new FirefoxDriver(binary, createFirefoxProfile(),createDefaultCapabilitiesFirefox()); 

但是我必須做的,當我想用​​一個便攜式的Firefox 48 ?

回答

0

嘗試一樣的,你正在使用的46只改變僅僅是用setCapability("marionette", true);如下爲DesiredCapabilities: -

String marionetteDriverLocation = getClass().getClassLoader().getResource("[PATH_TO_GECKODRIVER]/wires.exe").getPath(); 
System.setProperty("webdriver.gecko.driver", marionetteDriverLocation); 

DesiredCapabilities capabilities = DesiredCapabilities.firefox(); 
capabilities.setCapability("marionette", true); 

FirefoxBinary binary = new FirefoxBinary(new File(firefoxPortablePath)); 

WebDriver driver = new FirefoxDriver(binary, createFirefoxProfile(), capabilities); 
+0

其相同的結果,而不提線木偶=真。瀏覽器啓動,但顯示一個白色的窗口。 是否有可能,FF48的geckodriver只適用於Selenium3?我使用gecko0.9.0,因爲更新的需要WebDriver3/Java8 – Pirax

+0

你目前的硒版本是什麼? –

+0

Selenium 2.53.1 geckodriver-v0.9.0-win64 Firefox 48.0 Btw。當我使用MarionetteDriver與FF便攜式44它有或沒有理想的帽子marionette = true – Pirax

2

最後的作品。壁虎0.8.0或0.9.0沒有區別。非常感謝你@Saurabh Gaur 你讓我的一天!

工作代碼:

String marionetteDriverLocation = getClass().getClassLoader().getResource("[PATH_TO_GECKODRIVER]//wires.exe").getPath(); 
System.setProperty("webdriver.gecko.driver",marionetteDriverLocation); 
DesiredCapabilities capabilities = createDefaultCapabilitiesFirefox(); 
capabilities.setCapability("marionette", true); 
WebDriver driver = new MarionetteDriver(capabilities);