File torProfileDir = new File( "...\\Tor Browser\\Data\\Browser\\profile.default"); FirefoxBinary binary = new FirefoxBinary(new File( "...\\Tor Browser\\Start Tor Browser.exe")); FirefoxProfile torProfile = new FirefoxProfile(torProfileDir); torProfile.setPreference("webdriver.load.strategy", "unstable"); try { binary.startProfile(torProfile, torProfileDir, ""); } catch (IOException e) { e.printStackTrace(); }
public FirefoxBinary startProfile(FirefoxProfile profile, int port) throws IOException { FirefoxBinary binaryToUse = binary; if (binary == null) { binaryToUse = new FirefoxBinary(); } FirefoxProfile profileToUse = profile.createCopy(port); binaryToUse.clean(profileToUse); binaryToUse.startProfile(profileToUse); return binaryToUse; }
FirefoxDriver firefoxDriver; File torProfileDir = new File("C:\\tor\\Tor Browser\\Browser\\TorBrowser\\Data\\Browser\\profile.default"); FirefoxBinary binary = new FirefoxBinary(new File( "C:\\tor\\Tor Browser\\Browser\\firefox.exe"));//C:\tor\Tor Browser\Browser FirefoxProfile torProfile = new FirefoxProfile(torProfileDir); torProfile.setPreference("webdriver.load.strategy", "unstable"); binary.startProfile(torProfile, torProfileDir); FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("network.proxy.type", 1); profile.setPreference("network.proxy.socks", "127.0.0.1"); profile.setPreference("network.proxy.socks_port", 9150);
public void clean(FirefoxProfile profile) throws IOException { startProfile(profile, "-silent"); try { waitFor(); } catch (InterruptedException e) { throw new WebDriverException(e); } if (Platform.getCurrent().is(Platform.WINDOWS)) { while (profile.isRunning()) { sleep(500); } do { sleep(500); } while (profile.isRunning()); } }
File torProfileDir = new File("C:\\Users\\Chambers\\Desktop\\Tor Browser\\Browser\\TorBrowser\\Data\\Browser\\profile.default"); FirefoxBinary binary = new FirefoxBinary(new File("C:\\Users\\Chambers\\Desktop\\Tor Browser\\Browser\\firefox.exe")); FirefoxProfile torProfile = new FirefoxProfile(torProfileDir); torProfile.setPreference("webdriver.load.strategy", "unstable"); try { binary.startProfile(torProfile, torProfileDir, ""); } catch (IOException e) { e.printStackTrace(); } FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("network.proxy.type", 1); profile.setPreference("network.proxy.socks", "127.0.0.1"); profile.setPreference("network.proxy.socks_port", 9150); profile.setPreference("network.proxy.socks_version", 5); profile.setPreference("places.history.enabled", false); profile.setPreference("privacy.clearOnShutdown.offlineApps", true); profile.setPreference("privacy.clearOnShutdown.passwords", true); profile.setPreference("privacy.clearOnShutdown.siteSettings", true); profile.setPreference("privacy.sanitize.sanitizeOnShutdown", true); profile.setPreference("signon.rememberSignons", false); profile.setPreference("network.cookie.lifetimePolicy", 2); profile.setPreference("network.dns.disablePrefetch", true); profile.setPreference("network.http.sendRefererHeader", 0); profile.setPreference("network.proxy.socks_remote_dns", true); FirefoxDriver driver = new FirefoxDriver(profile); String firstCheck = ""; while (firstCheck == 0) { driver.get("http://kbhpodhnfxl3clb4.onion/"); .........................