Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 99408

Java and Tor Browser with Selenium

$
0
0

I have searched the web for a solution for hours, but they are all outdated or not working.

Does anyone have a working solution to get a connection with Java + Selenium + Tor Browser?

A short example would be enough.

My best try, with a "tor failed to start" error:

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

import java.io.File;
import java.util.concurrent.TimeUnit;

public class JSelenium {

public static void main(String[] args) {
    System.setProperty("webdriver.gecko.driver", "geckodriver.exe");
    System.setProperty("webdriver.firefox.marionette", "geckodriver.exe");
    FirefoxOptions options = new FirefoxOptions();
    FirefoxProfile torProfile = new FirefoxProfile(new File("xxx\\Tor Browser\\Browser\\TorBrowser\\Data\\Browser\\profile.default"));

    options.setBinary("xxx\\Tor Browser\\Browser\\firefox.exe");
    options.setProfile(torProfile);
    options.setCapability(FirefoxOptions.FIREFOX_OPTIONS, options);

    WebDriver driver = new FirefoxDriver(options);
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    driver.navigate().to("http://www.google.com");
}

}

Viewing all articles
Browse latest Browse all 99408

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>