简体   繁体   中英

How to open tor browser using watir?

With my ruby code I want to open Tor Browser instead of Firefox,for this I tried this code

path='C:\Tor Browser\App\tor.exe'
Selenium::WebDriver::Firefox.path = path
driver = Selenium::WebDriver.for :firefox
ie = Watir::Browser.new :firefox, :driver => driver

I got this error

c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/firefox/launcher.rb:79:in `connect_until_stable': unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055) (Selenium::WebDriver::Error::WebDriverError)
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/firefox/launcher.rb:37:in `block in launch'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/firefox/socket_lock.rb:20:in `locked'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/firefox/launcher.rb:32:in `launch'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/firefox/bridge.rb:24:in `initialize'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/common/driver.rb:31:in `new'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/common/driver.rb:31:in `for'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver.rb:67:in `for'
from C:/new_trademap/newTrademapTest.rb:28:in `<main>'

What should I have to do ? or there is any other way to do so?

links link1 google group link

The answer:

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=/Applications/TorBrowser.app/Contents/MacOS/TorBrowser.app/Contents/MacOS/firefox
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

Your path C:\\Tor Browser\\App\\tor.exe is not a path to firefox, it is a path to the Tor executable. What you will probably need to do is to modify your start-tor-browser script to run that tor.exe but not start firefox and then initialize Tor's Firefox separately.

Another option would be to modify your path of C:\\Tor Browser\\App\\tor.exe to the path for the TorBrowser's Firefox binary instead, now that the TorBrowser bundles Tor and Firefox into a single executable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM