如何使用Windows身份验证和Firefox运行Selenium NUnit测试?

时间:2015-05-27 15:33:33

标签: firefox selenium selenium-webdriver windows-authentication iis-express

我们的网络应用需要Windows身份验证。我有一个NUnit测试

  1. 启动托管我的网络应用的IIS Express进程。
  2. 启动FirefoxDriver并导航到网络应用。
  3. 不幸的是,它甚至没有要求凭据就会出现401.0 - Unauthorized错误。我习惯了Firefox要求凭据,在这种情况下你可以添加

            profile.SetPreference("network.ntlm.send-lm-response", true);
            profile.SetPreference("network.automatic-ntlm-auth.trusted-uris", "localhost");
    

    但出于某种原因,我只是立即使用登录用户匿名获得401。

    如何告诉Selenium / Firefox使用集成安全性?看看Windows任务管理器,我发现Firefox进程是“像我一样”启动的。

1 个答案:

答案 0 :(得分:1)

咄。我正在编辑错误的applicationhost.config。在64位操作系统上,相关的配置文件是C:\Program Files\IIS Express\AppServer\applicationhost.config(不是C:\Program Files (x86)\IIS Express\AppServer\applicationhost.config,我的不幸也存在)。

其中,我启用了Windows身份验证并禁用了匿名身份验证。然后Firefox开始要求提供凭据,然后我可以在传递给network.automatic-ntlm-auth.trusted-uris的个人资料中设置FirefoxDriver,如我所述。