IE11失败,并显示“不支持Netscape,请使用Internet Explorer". Selenium启动时出错 [英] IE11 fails with "Netscape is not supported please used internet explorer" error when launch by Selenium

查看:320
本文介绍了IE11失败,并显示“不支持Netscape,请使用Internet Explorer". Selenium启动时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相当老的网站需要维护,支持IE8及更高版本. 现在,我计划使用Selenium WebDriver(版本3.7.1)在站点上进行一些测试自动化.除了使用document.getElementById()的某些页面之外,几乎所有内容都可以正常运行.关键是,这些页面利用了IE11的功能",当没有元素与指定的ID匹配时,它将返回具有该ID的元素作为名称(如 这种差异是什么意思,是我问题的根本原因.最重要的是,如何解决这个问题?

I have a quite old website to be maintained, supports IE8 and above. Now I've a plan to do some test automation on the site, using Selenium WebDriver (version 3.7.1). Almost everything works well, except for some pages that use document.getElementById(). The point is, these pages utilize the "feature" of IE11 that when no element matches with specified ID, it then returns the element with that ID as name (as denoted in this thread).
And when brower (IE11) started by selenium, it fails to invoke that code (return a NULL, causing error).
Further investigate, I found that, when launched manually, invoking navigator.appName returns "Microsoft Internet Explorer", while returns "Netscape" in the other case.
What does that difference mean, and is that the root cause of my problem. And most important, how to resolve that?

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

I'm launching the page with this source code:

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

推荐答案

您提到的invoking navigator.appName returns "Microsoft Internet Explorer" while returns "Netscape" in the other case是一种罕见但盛行的方案.完整的错误显示为:

As you mentioned invoking navigator.appName returns "Microsoft Internet Explorer" while returns "Netscape" in the other case is a rare but prevailing scenario. The complete error reads as :

"Netscape is not supported please used internet explorer "

解决方案:

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

Solution:

To address this, you have to consider the following points:

  • Internet Explorer Driver 在真实的浏览器中运行并支持Javascript.
  • 尝试避免使用 Internet Explorer
  • 的任何 Add On
  • 如果必须使用任何必需的 Add On (对于所有IE9,IE10,IE11和Windows 8用户)

  • Internet Explorer Driver runs in a real browser and supports Javascript.
  • Try to avoid any Add On's with Internet Explorer
  • If you have to use any mandatory Add On's, (for all IE9,IE10,IE11 and Windows 8 users)

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 

这篇关于IE11失败,并显示“不支持Netscape,请使用Internet Explorer". Selenium启动时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆