通过Options类或DesiredCapabilities禁用IE弹出窗口阻止程序
我知道这可以手动完成一次,方法是转到工具> Internet选项>隐私,然后取消选中打开弹出窗口阻止程序 。 问题是如果我在另一台机器上运行这些测试,与弹出窗口相关的测试将失败。 有没有办法使用Internet Explorer
Options
或DesireCapabilities
来完成此任务。 我尝试过选项
var options = new InternetExplorerOptions { EnableNativeEvents = false }; options.EnsureCleanSession = true; options.UnexpectedAlertBehavior = InternetExplorerUnexpectedAlertBehavior.Dismiss;
我试过了
InternetExplorerUnexpectedAlertBehavior.Accept;
但是,没有奏效。 仍然阻止弹出窗口
导入此 – Microsoft.Win32
RegistryKey regKey = default(RegistryKey); regKey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Internet Explorer\\New Windows", true); regKey.SetValue("PopupMgr", 0); regKey.Close();