【发布时间】:2019-02-22 23:42:13
【问题描述】:
我遇到了这个异常:
线程“main”中的异常 java.lang.IllegalStateException:驱动程序可执行文件的路径必须由 webdriver.gecko.driver 系统属性设置;有关详细信息,请参阅https://github.com/mozilla/geckodriver。最新版本可以从https://github.com/mozilla/geckodriver/releases下载
这是我的代码:
String torPath = "C:\\Users\\camil\\Desktop\\Tor Browser\\Browser\\firefox.exe";
String profilePath = "C:/Users/camil/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);
torProfile.setPreference("webdriver.load.strategy", "unstable");
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setBinary(binary);
firefoxOptions.setProfile(torProfile);
FirefoxDriver driver = new FirefoxDriver(firefoxOptions);
【问题讨论】:
-
其他用户将您的问题标记为低质量和需要改进。我重新措辞/格式化您的输入,使其更容易阅读/理解。请查看我的更改以确保它们反映您的意图。如果您对我有其他问题或反馈,请随时给我留言。
-
除此之外:你试过东那个吗?将路径设置为系统属性?