Using wildcards possible?

Best practices, code snippets for common functionality, examples, and guidelines.
roxter
Posts: 22
Joined: Thu May 12, 2016 10:18 am

Using wildcards possible?

Post by roxter » Thu Sep 08, 2016 8:40 am

Hi!
I have a question regarding the use of "wildcards" or regular expressions.
My problem is I have to perform a click action on this element:
.//div[#'logo']/span[2]/?/?/a[@innertext='Techa 2.0.0-rc.1']

Well as the application version changes the name of the element will change to Techa 2.0.0-rc.2 and so on....
How can I solve this problem like this with wildcards Techa 2.0.0-rc.* ?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3914
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Using wildcards possible?

Post by odklizec » Thu Sep 08, 2016 8:50 am

Hi,

Yes, it is possible to use regular expressions in xpath. You just need to use '~' instead of '=' in xpath expression. I would suggest you to start with Ranorex xpath basics, described here:
http://www.ranorex.com/support/user-gui ... xpath.html
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

roxter
Posts: 22
Joined: Thu May 12, 2016 10:18 am

Re: Using wildcards possible?

Post by roxter » Thu Sep 08, 2016 9:06 am

Hi!
Thank you for your answer. Could you help me with the shown example. How would it have to look like if I would like to check only for "Techa".

Best wishes

roxter
Posts: 22
Joined: Thu May 12, 2016 10:18 am

Re: Using wildcards possible?

Post by roxter » Thu Sep 08, 2016 9:10 am

I got it, it is quite simple I used ^Tech :-)
Thank you very much!

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3914
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Using wildcards possible?

Post by odklizec » Thu Sep 08, 2016 9:12 am

Hi,
Try this xpath (matches all elements with innertext starting with 'Techa'):
.//div[#'logo']/span[2]/?/?/a[@innertext~'^Techa']
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration