webdriver java a标签_java-使用Selenium WebDriver运行TOR浏览器

我目前正在尝试使用Selenium WebDriver(JAVA)2.53和Firefox 43.0执行TOR 6.0.4.我已经按照这篇文章Using Selenium WebDriver with Tor的说明进行操作,但是将TOR的profilePath加载到Firefox Binary时出现错误.我已经看到可以通过将TOR profile.default存档加载到firefox binaty中来吃午饭,但是当我用该配置文件实例化二进制文件时,我得到了一个驱动程序信息:driver.version:未知.我一直尝试更改Firefox版本.在启动驱动程序的代码下面.林还使用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.我更改了路径,正在工作.还要解决我没有将配置文件和二进制文件发送给驱动程序构造函数的问题

"C:\\Users\\Jose Bernhardt\\Desktop\\Tor Browser\\Browser\\firefox.exe"

FirefoxDriver driver = new FirefoxDriver(binary, torProfile);

标签:selenium,tor,webdriver,java

来源: https://codeday.me/bug/20191118/2026762.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值