Selenium WebDriver将Firefox路径更改为Tor [英] Selenium WebDriver Change Firefox path to Tor
本文介绍了Selenium WebDriver将Firefox路径更改为Tor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将ruby中的webdriver更改为打开Tor浏览器,而不是默认的firefox浏览器.我正在使用以下代码,并且在运行此代码之前已打开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
我收到以下错误:
unable to obtain stable firefox connection in 60 seconds
我认为我可能链接到错误的Tor文件.
I think I might be linking to the wrong tor file.
推荐答案
以下内容适用于Ubuntu Linux 15.04上的selenium-webdriver 2.48.1和Tor Browser Bundle 5.0.3.
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/')
这篇关于Selenium WebDriver将Firefox路径更改为Tor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文