How to write xpath with contains ID using TestCafé?

Viewed 1029

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")]

I would like to write above xpath in TestCafé Selector Is it possible to do?

1 Answers

I believe this is not supported. See here.

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

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!

Related