normalize-space Xpath query not possible?

Ranorex Studio, Spy, Recorder, and Driver.
sdz
Posts: 3
Joined: Mon May 03, 2021 3:59 pm

normalize-space Xpath query not possible?

Post by sdz » Thu May 27, 2021 3:06 pm

Hi,

why is this query invalid and what would be the appropriate alternative?

Code: Select all

/element[normalize-space(@text)='L']

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

Re: normalize-space Xpath query not possible?

Post by odklizec » Fri May 28, 2021 7:14 am

Hi,

I'm afraid, this keyword is not supported by Ranorex implementation of xpath. What you can use, is regex like this, which should return any element, regardless of leading/trailing spaces...

Code: Select all

/element[@text~(?<!\S)L(?!\S)]
or like this for 'any' text...

Code: Select all

/element[@text~(?<!\S).*(?!\S)]
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

sdz
Posts: 3
Joined: Mon May 03, 2021 3:59 pm

Re: normalize-space Xpath query not possible?

Post by sdz » Tue Jun 01, 2021 8:30 am

Is it possible to also apply a variable instead of a fixed string?

Like

(?<!\S)$var(?!\S)

does not seem to work...

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

Re: normalize-space Xpath query not possible?

Post by odklizec » Tue Jun 01, 2021 8:49 am

Hi,

This should do the trick...

Code: Select all

/element[@text~'(?<!\S)' + $var + '(?!\S)']
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

richardferrym
Posts: 3
Joined: Wed Mar 08, 2023 5:05 am

Re: normalize-space Xpath query not possible?

Post by richardferrym » Mon Mar 13, 2023 3:52 am

Hi,

This should do the trick google account manager apk

Code: Select all

/element[@text~'(?<!\S)' + $var + '(?!\S)']
nice, it works for me