2016-08-24 161 views
3

我正在嘗試使用Selenium WebDriver(JAVA)2.53和Firefox 43.0執行TOR 6.0.4。我按照這篇文章Using Selenium WebDriver with Tor的說明操作,但是在將TOR的profilePath加載到Firefox二進制文件時遇到錯誤。我已經看到可以通過將TOR profile.default歸檔文件加載到firefox binaty來午餐TOR,但是當使用配置文件實例化二進制文件時,我得到了Driver info:driver.version:unknown。我試圖改變Firefox的版本,仍然。在我啓動驅動程序的代碼下面。我也使用Windows。用Selenium WebDriver運行TOR瀏覽器

String torPath = "C:\\Users\\Jose Bernhardt\\Desktop\\Tor Browser\\Start Tor Browser.exe"; 
    String profilePath = "C:\\Users\\Jose Bernhardt\\Desktop\\Tor Browser\\Browser\\TorBrowser\\Data\\Browser\\profile.default"; 

    File torProfileDir = new File(profilePath); 
    FirefoxBinary binary = new FirefoxBinary(new File(torPath)); 
    FirefoxProfile torProfile = new FirefoxProfile(torProfileDir); 
    FirefoxDriver driver = new FirefoxDriver(); 
    driver.get("http://www.google.com/webhp?complete=1&hl=en"); 

見拋出的異常如下:

Exception in thread "main" org.openqa.selenium.WebDriverException: Specified firefox binary location does not exist or is not a real file: C:\Users\Jose Bernhardt\Desktop\Tor Browser\Start Tor Browser.exe 

回答

3

看來,我是加載Tor.exe,而是我不得不從Tor的檔案加載firefox.exe。我改變了我的路,並正在工作。此外,修復我沒有發送配置文件和二進制驅動程序的構造函數

"C:\\Users\\Jose Bernhardt\\Desktop\\Tor Browser\\Browser\\firefox.exe" 
FirefoxDriver driver = new FirefoxDriver(binary, torProfile); 
+0

現在應該使用FireFoxOptions來代替。此構造函數重載現在已被棄用。 http://imgur.com/tAnzNhs –

相關問題