Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/478.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript '$x';未定义,同时在IE11控制台中验证webdriver的Xpath_Javascript_Internet Explorer_Xpath_Console_Webdriver - Fatal编程技术网

Javascript '$x';未定义,同时在IE11控制台中验证webdriver的Xpath

Javascript '$x';未定义,同时在IE11控制台中验证webdriver的Xpath,javascript,internet-explorer,xpath,console,webdriver,Javascript,Internet Explorer,Xpath,Console,Webdriver,使用selenium webdriver自动化组织web应用程序,它仅支持IE浏览器。在IE11浏览器控制台中验证Xpath时,我收到了错误,因为“$x”未定义 Xpath://a[@id='gb\u 70'] 链接:->登录按钮 在IE11控制台中验证Xpath:$x(“//a[@id='gb\u 70']) 错误:“$x”未定义您必须使用文档。请评估方法以测试IE中的xpath // evaluate the xpath and get the matching nodes (similar

使用selenium webdriver自动化组织web应用程序,它仅支持IE浏览器。在IE11浏览器控制台中验证Xpath时,我收到了错误,因为“$x”未定义

Xpath:
//a[@id='gb\u 70']

链接:->登录按钮

在IE11控制台中验证Xpath:
$x(“//a[@id='gb\u 70'])


错误:
“$x”未定义

您必须使用
文档。请评估
方法以测试IE中的xpath

// evaluate the xpath and get the matching nodes (similar to selenium findelements())
elements = document.evaluate("//input[@class='gLFyf gsfi']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
// to get the number of items matched (similar to selenium findelements().size())
elements.snapshotLength
// get the first element node (similar to selenium findelements().get(0))
elements.snapshotItem(0)
如果没有与给定xpath匹配的元素节点,
元素.snapshotLength
将为
0
。如果有多个元素与xpath匹配,则为
>2


这里是获取有关方法的更多信息的链接。

您必须使用
文档。评估
方法以测试IE中的xpath

// evaluate the xpath and get the matching nodes (similar to selenium findelements())
elements = document.evaluate("//input[@class='gLFyf gsfi']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
// to get the number of items matched (similar to selenium findelements().size())
elements.snapshotLength
// get the first element node (similar to selenium findelements().get(0))
elements.snapshotItem(0)
如果没有与给定xpath匹配的元素节点,
元素.snapshotLength
将为
0
。如果有多个元素与xpath匹配,则为
>2


下面是获取有关该方法的更多信息的链接。

Internet Explorer现在没有,也从来没有,一个基于HTML的本机XPath DOM引擎。因此,开发工具
$x()
快捷方式在IE开发工具中不起作用也就不足为奇了。Selenium在IE中完成的任何XPath处理都是使用JavaScript XPath引擎完成的。您可以尝试加载这样一个库并使用
文档。使用它评估
以使用XPath处理页面DOM。

Internet Explorer现在没有,也从来没有本地的XPath over HTML DOM引擎。因此,开发工具
$x()
快捷方式在IE开发工具中不起作用也就不足为奇了。Selenium在IE中完成的任何XPath处理都是使用JavaScript XPath引擎完成的。您可以尝试加载这样一个库并使用
document.evaluate
来使用XPath处理页面DOM。

我已经用document.evaluate方法验证了XPath,但由于“XPathResult”未定义,我收到了另一个错误。检查此链接以获取参考您的浏览器IE版本是什么?我已使用document.evaluate方法验证了xpath,但由于“XPathResult”未定义,我收到另一个错误。检查此链接以获取参考您的浏览器IE版本是什么?