I am having issues connecting to Tor via Ruby - Watir webdriver.

I use the Tor Browser Bundle. The problem is that when I try to connect via Watir (Selenium) I cannot seem to open Tor instead of regular Firefox.

Looking at similar issues I've tried the following:

require 'watir-webdriver'

profile = Selenium::WebDriver::Firefox::Profile.new

profile['network.proxy.socks'] = '' #the proxy tor uses
profile['network.proxy.socks_port'] = 9150 #I cannot use 9050, 9150 works when I use Tor
profile['network.proxy.type'] = 1

browser = Watir::Browser.new :firefox, :profile => profile
browser.goto [an .onion website]

When I use the before-mentioned code I nonetheless still open the normal firefox browser, and cannot connect to onion sites.

Any thoughts? Is there another way in which I need to connect the Tor browser to my webdriver profile?

  • Tor isn't Firefox. Yes, they're built on the same open source project, but they're completely different executables. There are some other questions like this, but they involve swapping out the path to firefox with the path to TorBrowser. None have gotten it working yet.. Commented Jul 15, 2014 at 11:13

2 Answers 2


First, open the Tor browser (it needs to be running already). Then, in your code, make sure to simply start with:

Selenium::WebDriver::Firefox::Binary.path='{location of start_tor_browser*}'
browser = Watir::Browser.new :firefox

*In my case: /home/tor/tor-browser_en-US/start-tor-browser

Nothing else is required - don't bother messing with profile

(hehe, credits to https://stackoverflow.com/questions/24305345/cant-connect-to-tor-firefox-via-watir)


Use normal Firefox, not the one shipped in TBB : it's a bit different one, and Selenium's troubles with it are well-known. The core of the problems is that it is a Long-Term support version WITH patches from a newer versions of FF, but it identivies it's version number as lower(older) one, and that's blows up alot of add-ons' minds. Use FoxyProxy in regular FF and you will be just fine =) Figured it iut some years ago myself after a night of trouble-googling

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .