英文:
How uses Xpath 2.0 in Katalon Studio
问题
Sure, here is the translation:
我想知道如何在Katalon Studio中使用XPath 2.0查询?我需要使用ends-with
匹配。我发现我尝试使用过的任何浏览器(包括Chrome,Firefox,Edge和IE)都不支持XPath 2.0查询。在这种情况下,我如何在Web测试中使用这些查询?
英文:
I want to know how can I use the XPath 2.0 queries in Katalon Studio? I need to use an ends-with
match. I found out that any browsers that I have tried to use (including Chrome, Firefox, Edge, and IE) do not support XPath 2.0 queries. This way, how can I use those queries on a web test?
答案1
得分: 0
我认为 Katalon Studio
不支持 XPath 2.0 表达式(比如 ends-with
函数)。
但你有替代方案。假设你想选择下面的元素:
<div id="foo_bar">我喜欢stackoverflow</div>
如果你想通过属性来定位它,可以使用 CSS 选择器:
div[id$='_bar']
选择一个带有以“_bar”结尾的 id
属性的 div
元素。
如果你想通过内容来定位元素,可以使用以下 XPath(1.0):
//div[substring(.,string-length(.)-string-length('stackoverflow')+1)="stackoverflow"]
选择一个内容以“stackoverflow”结尾的 div
元素。
将来如果你需要测试你的 XPath 1.0/2.0 表达式,你可以使用以下网络服务:
- http://xpather.com/
- https://www.freeformatter.com/xpath-tester.html
- http://videlibri.sourceforge.net/cgi-bin/xidelcgi
英文:
I don't think Katalon Studio
supports XPath 2.0 expressions (like ends-with
function).
But you have alternatives. Assuming you want to select the following element :
<div id="foo_bar">I love stackoverflow</div>
If you want to target it with its attribute, use a CSS selector :
div[id$='_bar']
Select a div
element whith an id
attribute which ends ($=
) with "_bar"
If you want to target the element with its content, use the following XPath (1.0) :
//div[substring(.,string-length(.)-string-length('stackoverflow')+1)="stackoverflow"]
Select a div
element with content ending with "stackoverflow".
In the future, if you need to test your XPath 1.0/2.0 expressions, you can use the following webservices :
专注分享java语言的经验与见解,让所有开发者获益!
评论