How to call Tor browser using Selenium testing framework using Java?

I have downloaded Tor and I have started IDE with Selenium JARs included.

I want to open Tor browser using selenium with Java and want to work on web URL.


2 Answers 2


Tor Browser is essentially Firefox, with a couple of patches. I don't think that the patches would affect the use of Selenium when compared to normal Firefox.

The Selenium documentation shows how to create a Firefox based WebDriver project.

The FirefoxDriver in particular can take parameters to the location of Firefox, and the profile to use. You should update these to point to the TorBrowser. The useExisting flag looks promising for once you've started the Tor Browser Bundle.

I haven't tested any of this, but I expect this is enough to point you in the right direction. I expect someone else will come along and contribute a more verbose answer.


If you just want to remote-control the Tor Browser, have a look at Marionette from Mozilla. It is built into the Tor Browser (and every other current Firefox). You enable it on the command line by calling

Browser/firefox -marionette

(inside the bundle). You initialize via

from marionette import Marionette
client = Marionette('localhost', port=2828);

and load a new page for example via


There is a tutorial (and further documentation) at readthedocs.

You must log in to answer this question.