Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/332.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
如何使用SeleniumWebDriver(java)使用tor浏览器?到目前为止,我已经尝试了下面的代码,但得到的消息是:';tor无法启动';_Java_Selenium_Selenium Webdriver_Automation_Tor - Fatal编程技术网

如何使用SeleniumWebDriver(java)使用tor浏览器?到目前为止,我已经尝试了下面的代码,但得到的消息是:';tor无法启动';

如何使用SeleniumWebDriver(java)使用tor浏览器?到目前为止,我已经尝试了下面的代码,但得到的消息是:';tor无法启动';,java,selenium,selenium-webdriver,automation,tor,Java,Selenium,Selenium Webdriver,Automation,Tor,到目前为止,我已经尝试了上面的代码,但收到消息:“tor无法启动”。是否有人可以帮助您了解上述代码需要做哪些更改。您正在尝试使用FireFox驱动程序。 请尝试使用其自述文件中指定的TorBrowserDriver: 或者,如果您想使用firefox,请使用GeckoDriver,可从下一个链接下载: import java.io.File; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.Fi

到目前为止,我已经尝试了上面的代码,但收到消息:“tor无法启动”。是否有人可以帮助您了解上述代码需要做哪些更改。

您正在尝试使用FireFox驱动程序。 请尝试使用其自述文件中指定的TorBrowserDriver:

或者,如果您想使用firefox,请使用GeckoDriver,可从下一个链接下载:

import java.io.File;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxBinary;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.firefox.FirefoxProfile;

public class torr1 {

    public static void main(String[] args) {
        System.setProperty("webdriver.firefox.marionette",
                "C:\\Users\\ghorh\\Documents\\selenium-bazinga\\Drivers\\geckodriver.exe");
        String torPath = "C:\\Users\\ghorh\\Desktop\\Tor Browser\\Browser\\firefox.exe";
        String profilePath = "C:\\Users\\ghorh\\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);

        FirefoxOptions options = new FirefoxOptions();
        options.setBinary(binary);
        options.setProfile(torProfile);
        options.setCapability(FirefoxOptions.FIREFOX_OPTIONS, options);
        WebDriver driver = new FirefoxDriver(options);
        driver.get("http://google.co.in");

    }

}