Add Variable in Base xPath?

Ask general questions here.
ThomasMateo
Posts: 1
Joined: Sun May 24, 2020 9:30 am

Add Variable in Base xPath?

Post by ThomasMateo » Thu May 28, 2020 6:44 am

Based on the input (Missouri, Iowa, California) i have to modify the Base xPath in Ranorex repository.
If Missouri, it should be test.mo.google.com
if Iowa, it should be test.ia.google.com
if California it should be test.ca.google.com

/dom[@domain~'test+$domainURL+.google.com']

I have created a variable called domainURL and thru data binding passed a value for domainURL but it is not working.

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

Re: Add Variable in Base xPath?

Post by odklizec » Thu May 28, 2020 7:31 am

Hi,

The xpath with variable must look like this:
/dom[@domain='test.'+$domainURL+'.google.com']
I personally don't like the idea to have variables in DOM, because it means I have to bind every single recording using repo elements ;) So in situation like yours, I prefer to 'hardcode' the variable strings, like this:
/dom[@domain~'test.(mo|ia|ca).google.com']
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