Assign global variable value to repository variables from User code .

Ask general questions here.
jyothi2021
Posts: 2
Joined: Wed May 19, 2021 2:23 am

Assign global variable value to repository variables from User code .

Post by jyothi2021 » Wed May 19, 2021 2:28 am

I have created variable 'varDomain' in the reposiotory and mapped to dom (/dom[@domain=$varDomain]).
Then I created global parameter varaible 'AppDomain' at Test Suite level.
I want to assign global parameter value to repository variables from usercode during runtime.
I am using following line:
Repository.Instance.varDomain = Testsuite.Current.Parameters["AppDomain"]
It is working fine as expected. But I have to use above line for every user code method which uses repo items.
It's like a repetitive. Is there any better way to handle this scenario?


Thanks in advance

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

Re: Assign global variable value to repository variables from User code .

Post by odklizec » Thu May 20, 2021 7:23 am

Hi,

The solution is not to use variable in domain name :) I personally hated the need to databind variable with every single recording/code module using repository. So I simply replaced variable with multiple hardcoded domain names, separated by conditional keyword "or". Like this...

Code: Select all

/dom[@domain='doamin_A' or @domain='domain_B' or @domain='domain_C']
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

jyothi2021
Posts: 2
Joined: Wed May 19, 2021 2:23 am

Re: Assign global variable value to repository variables from User code .

Post by jyothi2021 » Fri May 21, 2021 4:26 am

Thank you for your suggestion.