2

使用我的 ruby​​ 代码,我想打开 Tor 浏览器而不是 Firefox,为此我尝试了此代码

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

我收到了这个错误

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>'

我应该怎么做?或者还有其他方法吗?

链接 link1 谷歌组链接

4

2 回答 2

0

答案:

首先,打开 Tor 浏览器(它需要已经运行)。然后,在您的代码中,确保简单地从以下内容开始:

Selenium::WebDriver::Firefox::Binary.path=/Applications/TorBrowser.app/Contents/MacOS/TorBrowser.app/Contents/MacOS/firefox
browser = Watir::Browser.new :firefox

*就我而言:/home/tor/tor-browser_en-US/start-tor-browser

不需要其他任何东西 - 不要打扰个人资料

于 2014-07-15T11:16:40.113 回答
-1

您的路径 C:\Tor Browser\App\tor.exe不是 Firefox 的路径,而是 Tor 可执行文件的路径。您可能需要做的是修改您的 start-tor-browser 脚本以运行该 tor.exe 但不启动 Firefox,然后单独初始化 Tor 的 Firefox。

另一种选择是将您的路径修改C:\Tor Browser\App\tor.exe为 TorBrowser 的 Firefox 二进制文件的路径,因为 TorBrowser 将 Tor 和 Firefox 捆绑到一个可执行文件中。

于 2013-10-08T14:24:49.487 回答