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: 6553
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

User avatar
DrPsyche
Posts: 6
Joined: Tue Dec 11, 2018 12:27 pm

Re: Add Variable in Base xPath?

Post by DrPsyche » Wed Mar 17, 2021 7:33 am

ThomasMateo wrote:

if California, it should be test.ca.google.com
if Iowa, it should be test.ia.google.com
If Missouri, it should be test.mo.google.com
Could you please help me understand how I can pass values to repository variables to write my essay fast test.

_
If you made the same mistake like I did with the default value, here's a helpful link:
Define test and variables >>

https://www.ranorex.com/help/latest/ran ... n-testing/