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

How to run a Selenium NUnit test using Windows Authentication with Firefox?

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

  1. 启动托管我的网络应用程序的 IIS Express 进程。
  2. 启动 FirefoxDriver 并导航到网络应用程序。

不幸的是,它甚至没有要求凭据就收到了 401.0 - Unauthorized 错误。我习惯于 Firefox 要求提供凭据,在这种情况下您可以添加

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

但出于某种原因,我立即收到 401 Logon User: Anonymous.

如何告诉 Selenium/Firefox 使用集成安全性?查看 Windows 任务管理器,我看到 Firefox 进程已启动 "as me"。

呃。我编辑错了applicationhost.config。在 64 位 OS 上,相关的配置文件是 C:\Program Files\IIS Express\AppServer\applicationhost.config(不是 C:\Program Files (x86)\IIS Express\AppServer\applicationhost.config,不幸的是它也存在)。

其中,我启用了 Windows 身份验证并禁用了匿名身份验证。然后 Firefox 开始询问凭据,然后我可以在传递给 FirefoxDriver 的配置文件中设置 network.automatic-ntlm-auth.trusted-uris,正如我的问题所概述的那样。