如何使用TestCafé编写包含ID的xpath? [英] How to write xpath with contains ID using TestCafé?

查看:68
本文介绍了如何使用TestCafé编写包含ID的xpath?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要在TestCafé选择器中使用包含"关键字来获取动态ID.

Need to take the dynamic ID using "contains" keyword in TestCafé selector.

html:

<div id="content-body-14269002-17290547">

xpath:

//div[contains(@id,"content-body")]

我想在TestCafé中的xpath上方写选择器有可能吗?

推荐答案

我认为不支持此功能.请参见此处.

I believe this is not supported. See here.

我建议处理此类情况的一个好的解决方法是使用 xpath-to-css 软件包.

A good workaround I can recommend to handle such cases is to use xpath-to-css package.

此外,您可以为此创建一个CSS选择器,部分 id 匹配的CSS选择器将为:

Also, you can just create a CSS selector for this case, CSS Selector for partial id match will be:

div[id*='content-body']

希望这会有所帮助.祝你好运!

Hope this is helpful. Good luck!

这篇关于如何使用TestCafé编写包含ID的xpath?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆