Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium WebDriver Change Firefox path to Tor

I'm trying to change webdriver in ruby to open a tor browser instead of the default firefox broswer. I'm using the following code and I have a tor browser open before I run this code.

path='C:\Users\Bonnnie\Downloads\Tor Browser\App\tor.exe'
Selenium::WebDriver::Firefox.path = path
driver = Selenium::WebDriver.for :firefox

I get the following error:

unable to obtain stable firefox connection in 60 seconds

I think I might be linking to the wrong tor file.

like image 383
Richard Friedman Avatar asked Apr 01 '26 17:04

Richard Friedman


1 Answers

The following worked for me with selenium-webdriver 2.48.1 and Tor Browser Bundle 5.0.3 on Ubuntu Linux 15.04.

require 'selenium-webdriver'

tor_dir = '/opt/tor-browser_en-US'
# The Tor binary relies on these shared libraries
ENV['LD_LIBRARY_PATH']= [
  File.join(tor_dir, 'Browser/'),
  File.join(tor_dir, 'Browser/TorBrowser/Tor/')
].join(':')
Selenium::WebDriver::Firefox::Binary.path =
  File.join(tor_dir, 'Browser/firefox')
profile = Selenium::WebDriver::Firefox::Profile.new(
  File.join(tor_dir, 'Browser/TorBrowser/Data/Browser/profile.default'))
driver = Selenium::WebDriver.for :firefox, :profile => profile
driver.get('https://check.torproject.org/')
like image 100
Chris Oei Avatar answered Apr 03 '26 09:04

Chris Oei



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!