Ian*_*hek 16 selenium xpath google-chrome selenium-chromedriver
我的印象是所有最新的浏览器现在都使用XPath 2.当我使用lower-case()和uppser-case()(版本2中引入的功能)时,Chrome会抛出语法错误.然而,他们较旧的替代品translate()工作正常.
这是一个错误还是最新的Chrome实际上使用XPath 1?是否有命令/方法来找出XPath版本?
// Finds the element as expected.
$x('//h2/text()[. = "Delete"]')
// Doesn't find the element (also expected).
$x('//h2/text()[. = "delete"]')
// SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//h2/text()[lower-case(.) = "delete"]' is not a valid XPath expression.
$x('//h2/text()[lower-case(.) = "delete"]')
Run Code Online (Sandbox Code Playgroud)
kjh*_*hes 18
不,Chrome使用XPath 1.0.
您可以将XPath表达式简化为v2.0函数以查看:
$x("lower-case('ABC')")
SyntaxError: Failed to execute 'evaluate' on 'Document': The string 'lower-case('ABC')' is not a valid XPath expression.
Run Code Online (Sandbox Code Playgroud)
尝试任何其他XPath 2.0函数current-date()会产生类似的错误.
除了这些探测之外,没有内置的方法可以明确地确定XPath实现的版本.
另一方面,XSLT system-property('xsl:version')用于确定版本1.0与2.0.
| 归档时间: |
|
| 查看次数: |
5457 次 |
| 最近记录: |