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

All I can do is to show you some workaounds.

Alternative to the XPath2.0 matches() function:

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

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:

The following article describes how to live with XPath1.0, without regular expression and ends-with which were added at XPath 2.0

Just for your interest, I made a demo project where I verify if today’s date is displayed in a web page. I used XPath contains() function. I did not need matches() function at all.

I will check it out thank you !

Of course I also try

  • with ‘^’ and ‘$’
  • with ‘/’ and ‘/g’

Issue exist for mobile too :roll_eyes:

  • No parent
  • Selection method: Attributes
  • Simple regex to handle a popup in multi language:
    (Not Now|Plus tard)
    (Allow|Autoriser)

@duyluong ,

Please let us know if their is workaround for this issue.
The matches regex does not work for mobile too.

Locator :
/*[@class = ‘android.widget.TextView’ and (matches(text(), ‘\b\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\b’) or matches(., ‘\b\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\b’))]

@bttestmobil

Could you show us a screenshot of your application under test? Do you want to find elements that contain IP Address?

@kazurayam,

Thanks for the quick response.
Yes the text attribute of element has dynamic IP address which needs to be validated.

Cheers,

Please have a look at the following new post

1 Like