4
我使用Selenium 2.53.0 Java,Tor 6.0.4和Firefox 43。我使用Firefoxprofile()加載profile.default存檔, Firefoxbinary()與firefox.exe。 Tor的啓動,但它不啓動,它顯示兩個錯誤:無法連接到Tor控制端口和Tor未能啓動。使用Selenium WebDriver啓動TOR瀏覽器時發生錯誤
我按照這個帖子Using Selenium WebDriver with Tor來設置Firefox驅動程序。
請參閱下面的代碼。謝謝!
String torPath = "C:\\Users\\Jose Bernhardt\\Desktop\\Tor Browser\\Browser\\firefox.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(binary, torProfile);
這些都是拋出的異常:
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
Exception in thread "main" org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(C:\Users\Jose Bernhardt\Desktop\Tor Browser\Browser\firefox.exe) on port 7055; process output follows