微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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);

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐