嗨我在这里找到了一个部分解决方案: Update Registry Key to "Prompt for User name and password login"
[AssemblyInitialize]
public static void AssemblyInitialize(TestContext testContext)
{
long setPrompt = -1;
string regEditKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1";
using (RegistryKey regKeys = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry64).OpenSubKey(regEditKey, true))
{
if (regKeys != null)
{
setPrompt = Convert.ToInt64(regKeys.GetValue("1A00"));
if (setPrompt != 65536)
{
regKeys.SetValue("1A00", (object)65536, RegistryValueKind.QWord);
regKeys.Close();
regKeys.Flush();
}
}
}
}
问题是,我希望IE(11)浏览器在开始测试(prompt for user name and password
)时要求提供凭据(Startup
),然后返回Automatic logon with current user name and password
Teardown
。我不确定在完成测试时该怎么做。