【问题标题】:IE11 fails with "Netscape is not supported please used internet explorer" error when launch by SeleniumIE11 在 Selenium 启动时因“不支持 Netscape,请使用 Internet Explorer”错误而失败
【发布时间】:2017-12-11 11:34:30
【问题描述】:

我有一个很老的网站要维护,支持IE8及以上。 现在我计划使用 Selenium WebDriver(版本 3.7.1)在站点上进行一些测试自动化。除了一些使用 document.getElementById() 的页面外,几乎所有东西都运行良好。关键是,这些页面利用了 IE11 的“特性”,即当没有元素与指定 ID 匹配时,它会返回具有该 ID 作为名称的元素(如 this thread 所示)。
当浏览器(IE11)由 selenium 启动时,它无法调用该代码(返回 NULL,导致错误)。
进一步调查,我发现手动启动时,调用 navigator.appName 返回“Microsoft Internet Explorer”,而在另一种情况下返回“Netscape”。
这种差异是什么意思,这是我问题的根本原因。最重要的是,如何解决?

我正在使用此源代码启动页面:

DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
WebDriver driver = new InternetExplorerDriver(
                    new InternetExplorerOptions(ieCapabilities));
wait = new WebDriverWait(driver, 30);
driver.get(url);

【问题讨论】:

  • 能否检查一下是否与IE文档兼容模式有关。我怀疑它们在可能导致问题的两种情况下可能不同
  • 您使用的是哪个Selenium ClientJava/JavaScript ?

标签: javascript selenium internet-explorer-11


【解决方案1】:

正如您所提到的,invoking navigator.appName returns "Microsoft Internet Explorer" while returns "Netscape" in the other case 是一种罕见但普遍存在的情况。完整的错误读作:

"Netscape is not supported please used internet explorer "

解决方案:

要解决这个问题,您必须考虑以下几点:

  • Internet Explorer Driver 在真实浏览器中运行,支持 Javascript。
  • 尽量避免使用 Internet Explorer 的任何 Add On
  • 如果您必须使用任何强制性 Add On,(适用于所有 IE9、IE10、IE11 和 Windows 8 用户)

    1. Open the desired website in Internet Explorer
    2. Go to "Compatibility View settings" (image shown below)
    3. In a dialog box add your website in the list.
    e.g. if you are trying to use "ssconline.nic.in" , then add "nic.in" in the list 
    

【讨论】:

  • 你设置IE兼容性设置的建议救了我!!!将我的网站 URL 添加到兼容性列表后,它在 selenium 启动页面时正确打开了兼容模式,并且 javascript 按预期返回 navigator.appName 的“Microsoft Internet Explorer”。但是有人能帮我弄清楚,为什么由 Selenium 启动的 IE 拒绝自动打开兼容模式,就像手动启动时一样?
猜你喜欢
  • 1970-01-01
  • 2019-10-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-11-01
  • 2021-07-25
  • 2015-12-22
  • 1970-01-01
相关资源
最近更新 更多