【发布时间】:2014-10-08 16:43:31
【问题描述】:
在 Firefox 中使用 Selenium WebDriver 开始测试运行时出现“错误请求”异常。我将此问题追溯到主机配置文件(使用 Windows 7)。我机器上的 hosts 文件有这一行(当然,稍作编辑):
127.0.0.1 alias.set.by.security
这应该通过将 localhost 添加到该行来解决。问题是,我无法更改此文件,我们有一个依赖于此并覆盖我的权利的安全工具。 我发现了一个与此相关的问题,https://code.google.com/p/selenium/issues/detail?id=3280
但是,他们对如何使用修复程序有点神秘。有谁知道如何修复我的代码以使其正常工作(它无法正常工作)?
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference(FirefoxProfile.ALLOWED_HOSTS_PREFERENCE, "localhost");
driver = new FirefoxDriver(profile);
【问题讨论】:
-
您使用哪个版本的 webdriver?即使我的主机文件条目没有 127.0.0.1 的 localhost 值,我在运行 selenium 测试时也没有看到任何问题。
-
最新,2.43.1。现在使用我放在下面的代码可以正常工作
标签: java selenium selenium-webdriver automated-tests