Disable IE pop up blocker through Options class or

2019-05-23 15:06发布

I know this can be done manually once by going to Tools>Internet Options>Privacy and unchecking Turn on Pop-up Blocker. The problem is if I run these tests on a different machine the tests related to pop up window will fail. Is there a way to accomplish this using Options or DesireCapabilities for Internet Explorer. I have tried with options

var options = new InternetExplorerOptions { EnableNativeEvents = false };
options.EnsureCleanSession = true;
options.UnexpectedAlertBehavior = InternetExplorerUnexpectedAlertBehavior.Dismiss;

I have tried

InternetExplorerUnexpectedAlertBehavior.Accept;

But, did not work. Still blocks the pop up

enter image description here

1条回答
萌系小妹纸
2楼-- · 2019-05-23 15:46

Import this - Microsoft.Win32

RegistryKey regKey = default(RegistryKey);
regKey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Internet Explorer\\New Windows", true);
regKey.SetValue("PopupMgr", 0);
regKey.Close();
查看更多
登录 后发表回答