# Test Object with xpath selector using matches() function never works

**URL:** <https://forum.katalon.com/t/test-object-with-xpath-selector-using-matches-function-never-works/11822>\
**Category:** Bug Report\
**Tags:** katalon-studio, bugs-report\
**Created:** [July 3, 2018, 4:24am UTC](https://forum.katalon.com/t/test-object-with-xpath-selector-using-matches-function-never-works/11822 "2018-07-03T04:24:36Z")\
**Posts on this page:** 1\
**Showing post:** 21

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [May 15, 2020, 10:53pm UTC](https://forum.katalon.com/t/test-object-with-xpath-selector-using-matches-function-never-works/11822/21 "2020-05-15T22:53:13Z")

</div>

All I can do is to show you some workaounds.

Alternative to the XPath2.0 `matches()` function:

> [@Using regex to find the id](http://forum.katalon.com/t/using-regex-to-find-the-id/10116/4):
>
> Alternative to Regexp, you can use XPath expression: You can select a div element with id=“Donors\_1233klf323sd\_Ti” by the following xpath: //div[starts-with(@id, "Donors\_") and substring(@id, string-length(@id) - string-length('\_Ti')+1)="\_Ti"]

Alternative to the XPath2.0 `ends-with()` function:

> [@Customizing xpath generation](http://forum.katalon.com/t/customizing-xpath-generation/15801/5):
>
> Write a Groovy code which creates a Test Object on the fly. It will read an existing Test Object with xpath //button[@id=‘staticId1:dynamicId:staticId2’]/span It will translate the xpath into another one like //button[starts-with(@id,'staticId1') and ends-with(@id,'staticId2')]/span Then it will create a new Test Object using the generated xpath. XPath2.0 ends-with() function is not available to us. But alternative (very verbose) xpath expression can do the same query Let me work out for a…

In many cases (simple cases), the `contains` function of XPath 1.0 is useful, can be an alternative to `matches` function of XPath 2.0:

> **[XPath in Selenium: How to Find & Write? (Text, Contains, AND)](https://www.guru99.com/xpath-selenium.html#6)**
>
> XPath in Selenium: Learn XPath definition, Types, Basic XPath, Contains, OR & AND, Starts-with Function, XPath Axes Methods, and more.

---

_[View the full topic](https://forum.katalon.com/t/test-object-with-xpath-selector-using-matches-function-never-works/11822)._
