Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用Selenium WebDriver启动TOR浏览器时出错_Java_Selenium_Firefox_Tor - Fatal编程技术网

Java 使用Selenium WebDriver启动TOR浏览器时出错

Java 使用Selenium WebDriver启动TOR浏览器时出错,java,selenium,firefox,tor,Java,Selenium,Firefox,Tor,我正在使用Selenium2.53.0Java、Tor6.0.4和Firefox43。我正在用firefox执行tor,方法是用Firefoxprofile()加载profile.default归档文件,用firefox.exe加载Firefoxbinary()。Tor启动,但未启动,它显示两个错误:无法连接到Tor控制端口和Tor启动失败 我跟随这篇文章来设置Firefox驱动程序 请参见下面的代码。谢谢 String torPath = "C:\\Users\\Jose Bernhardt\

我正在使用Selenium2.53.0Java、Tor6.0.4和Firefox43。我正在用firefox执行tor,方法是用Firefoxprofile()加载profile.default归档文件,用firefox.exe加载Firefoxbinary()。Tor启动,但未启动,它显示两个错误:无法连接到Tor控制端口和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

我认为这是因为您使用了错误版本的firefox驱动程序

请尝试以下内容:

public WebDriver driver;
system.setproperty("webdriver.gecko.driver","path to your firefoxdriver");
driver = new FierfoxDriver();