【问题标题】:Disable IE pop up blocker through Options class or DesiredCapabilities通过 Options 类或 DesiredCapabilities 禁用 IE 弹出窗口阻止程序
【发布时间】:2015-03-27 17:40:21
【问题描述】:

我知道这可以通过转到工具>Internet 选项>隐私并取消选中打开弹出窗口阻止程序手动完成一次。问题是如果我在另一台机器上运行这些测试,与弹出窗口相关的测试将失败。有没有办法使用OptionsDesireCapabilities for Internet Explorer 来完成此操作。我已经尝试过选项

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

我试过了

InternetExplorerUnexpectedAlertBehavior.Accept;

但是,没有用。仍然阻止弹出窗口

【问题讨论】:

  • 你可以试试这个...ieCapabilities.setCapability("disable-popup-blocking", true);...它的java...
  • 对于类似的要求,我以编程方式在从机中更新注册表 - HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\New Windows ; PopupMgr 应该是 0
  • @VivekSingh 抱歉没用
  • @VinothS 谢谢。我实际上对以编程方式禁用更感兴趣
  • @Saifur ,实际上 Vinoth 试图说您可以在测试初始化​​方法中以编程方式(使用 c#)更新注册表。

标签: c# internet-explorer selenium selenium-webdriver webdriver


【解决方案1】:

导入这个 - Microsoft.Win32

RegistryKey regKey = default(RegistryKey);
regKey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Internet Explorer\\New Windows", true);
regKey.SetValue("PopupMgr", 0);
regKey.Close();

【讨论】:

  • 会试一试,然后回复你。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-05-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多