使用Selenium WebDriver运行TOR浏览器 [英] Run TOR browser with Selenium WebDriver

查看:187
本文介绍了使用Selenium WebDriver运行TOR浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试使用Selenium WebDriver(JAVA)2.53和Firefox 43.0执行TOR 6.0.4。我按照这篇文章中的说明使用Selenium WebDriver和Tor 但我得到了一个将TOR的profilePath加载到Firefox二进制文件时出错。我已经看到可以通过将TOR profile.default存档加载到firefox binaty来进行TOR午餐,但是当我使用配置文件实例化二进制文件时,我得到了驱动程序信息:driver.version:unknown。我试图改变firefox版本,但仍然。在我启动驱动程序的代码下面。我也在使用Windows。

Im currently trying to execute TOR 6.0.4 with Selenium WebDriver (JAVA) 2.53 and Firefox 43.0. I've followed the instructions from this post Using Selenium WebDriver with Tor but Im getting an error while loading the profilePath of TOR to the Firefox Binary. I've seen that is possible to lunch TOR by loading the TOR profile.default archive to the firefox binaty, but Im getting a Driver info: driver.version: unknown, when instantiating the binary with the profile. I've tried to change the firefox version and still. Below the code where I start the driver. Im also using Windows.

 String torPath = "C:\\Users\\Jose Bernhardt\\Desktop\\Tor Browser\\Start Tor Browser.exe";
    String profilePath = "C:\\Users\\Jose Bernhardt\\Desktop\\Tor Browser\\Browser\\TorBrowser\\Data\\Browser\\profile.default";

    File torProfileDir = new File(profilePath);
    FirefoxBinary binary = new FirefoxBinary(new File(torPath));
    FirefoxProfile torProfile = new FirefoxProfile(torProfileDir);
    FirefoxDriver driver = new FirefoxDriver();
    driver.get("http://www.google.com/webhp?complete=1&hl=en");

见下面抛出的异常:

Exception in thread "main" org.openqa.selenium.WebDriverException: Specified firefox binary location does not exist or is not a real file: C:\Users\Jose Bernhardt\Desktop\Tor Browser\Start Tor Browser.exe


推荐答案

似乎我正在加载Tor.exe而不是我必须从Tor存档加载firefox.exe。我改变了我的道路并且正在努力。还修复了我没有将配置文件和二进制文件发送到驱动程序构造函数

Seems that I was loading the Tor.exe and instead I had to load the firefox.exe from the Tor archive. I change my path to this and is working. Also fix that I was not sending the profile and the binary to the driver constructor

 "C:\\Users\\Jose Bernhardt\\Desktop\\Tor Browser\\Browser\\firefox.exe"
FirefoxDriver driver = new FirefoxDriver(binary, torProfile);

这篇关于使用Selenium WebDriver运行TOR浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆