IE11失败了"不支持Netscape请使用Internet Explorer" Selenium

时间:2017-12-04 11:01:17

标签: javascript selenium internet-explorer-11

我有一个很老的网站需要维护,支持IE8及以上版本。 现在,我计划使用Selenium WebDriver(版本3.7.1)在网站上进行一些测试自动化。除了一些使用document.getElementById()的页面外,几乎所有内容都运行良好。关键是,这些页面使用"功能"当IE11没有元素与指定ID匹配时,它返回具有该ID作为名称的元素(如this thread所示)。
当brlen(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);

1 个答案:

答案 0 :(得分:1)

正如您所提到的,ldd c++_app | grep boost libboost_iostreams.so.1.62.0 => not found 是一种罕见但普遍的情况。完整错误读作:

invoking navigator.appName returns "Microsoft Internet Explorer" while returns "Netscape" in the other case

解决方案:

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

  • "Netscape is not supported please used internet explorer " 在真实的浏览器中运行并支持Javascript。
  • 尝试使用 Internet Explorer Driver
  • 避免任何 Add On
  • 如果您必须使用任何强制性 Internet Explorer ,(适用于所有IE9,IE10,IE11和Windows 8用户)

    Add On

CompatibilityViewSettings_IE