简体   繁体   English

通过 Selenium 和 Java 使用 IEDriverServer 和 Internet Explorer 在 Microsoft Dynamics CRM 中出现 XPathEvaluator 未定义脚本错误

[英]XPathEvaluator is undefined’ script error in Microsoft Dynamics CRM using IEDriverServer and Internet Explorer through Selenium and Java

I am testing a CRM application using Selenium Java.我正在使用 Selenium Java 测试 CRM 应用程序。 There is a button on the CRM application which when clicked opens a new window. CRM 应用程序上有一个按钮,单击该按钮会打开一个新窗口。 When I run the test for this functionality, the new window opens and there is a Script Log Error which in the body says,当我运行此功能的测试时,新窗口打开,并且正文中出现一个脚本日志错误

ReferenceError: 'XPathEvaluator' is undefined at ( some http resource ) ReferenceError: 'XPathEvaluator' 在(某些 http 资源)处未定义

But when I try the same functionality manually, it works fine and does not cause any error.但是当我手动尝试相同的功能时,它工作正常并且不会导致任何错误。 What I am trying to understand is, what causes the XpathEvaluator is undefined error.我想了解的是,导致XpathEvaluator 未定义错误的原因是什么。

Any help to understand this error would be appreciated.任何帮助理解此错误的帮助将不胜感激。 Or some hint towards where I can start my investigation for the same.或者一些关于我可以从哪里开始调查的提示。

I have already checked the xpaths involved in clicking the button and opening the window.我已经检查了单击按钮和打开窗口所涉及的 xpath。 They are correct locators.它们是正确的定位器。

The versions I am using:我使用的版本:

  • Selenium: 3.14硒:3.14
  • IE: 11 IE: 11

This error message...这个错误信息...

ReferenceError: 'XPathEvaluator' is undefined

...implies that there was a ReferenceError while XML processing in Javascript . ...暗示在Javascript 中处理 XML时出现ReferenceError

@nzakas (Wrox Author), in the XML processing in Javascript section of his book Professional Javascript for Web Developers mentioned, historically there are some browsers that won't work with the XPathEvaluator . @nzakas(Wrox 作者)在他的书Professional Javascript for Web DevelopersXML processing in Javascript部分中提到,历史上有一些浏览器不能与XPathEvaluator He further stated that, users should use the corresponding methods pertaining to the specific Document to make up for the short coming in those browsers.他进一步表示,用户应该使用与特定文档相关的相应方法来弥补这些浏览器的不足。

Specifically, is the only browser that now doesn't support XPathEvaluator .具体来说, 是现在唯一不支持XPathEvaluator浏览器。 You can use selectNode() and selectSingleNode() on the DOM Document object instead (for IE only).您可以在DOM Document 对象上使用selectNode()selectSingleNode()代替(仅适用于 IE)。


This usecase这个用例

As per the article, Resolving the Error "XPathEvaluator' is undefined" this XPathEvaluator is undefined script error is often observed in Microsoft Dynamics CRM 2011 after upgrading to .根据文章, 解决错误“XPathEvaluator' 未定义”XPathEvaluator is undefined脚本错误在升级到后经常在Microsoft Dynamics CRM 2011 中观察到。 Further investigation revealed, any HTML resource that includes ClientGlobalContext.js (which is used to get the context of the parent form) will throw the error the error SCRIPT5009: 'XPathEvaluator' is undefined .进一步调查显示,任何包含ClientGlobalContext.js (用于获取父表单的上下文)的 HTML 资源都会抛出错误SCRIPT5009: 'XPathEvaluator' is undefined


Solution解决方案

A quick solution will be to add the following line to the <head> of your custom HTML documents that reference that particular JS file:一个快速的解决方案是将以下行添加到引用该特定JS文件的自定义 HTML 文档的<head>中:

<meta http-equiv="X-UA-Compatible" content="IE=10" />

This this line of the script is to force the browser to run the web resource in mode.这行脚本是强制浏览器以模式运行 web 资源。

Caution : The downside is that this functionality will be depreciated in , which is Microsoft's newly released Internet Explorer replacement.注意:缺点是此功能将在贬值,这是 Microsoft 新发布的Internet Explorer替代品。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM