我正在使用 selenium 和 perl 并在页面上有标签,要访问此标签,我有以下 xpath://*[text()='some here']
,需要获取该元素的完整 xpath 的问题,例如/html/body/table/tr/..../any other/and other/
,有没有selenium方法或者perl函数?寻找 perl 解决方案或任何其他可用的东西。
thanks
寻找 perl 解决方案或任何其他
工作的东西
这个 XPath 2.0 表达式:
string-join(for $node in ancestor-or-self::node()
return concat(('@')[$node/self::attribute()],
$node/name(),
(concat('[',
count($node/preceding-sibling::node()
[name()=$node/name()]) + 1,
']'))[$node/../node()
[name()=$node/name()][2]]),
'/')
Edit:较短的表达。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)