How do I create a repo variable linked to a datasource?

Best practices, code snippets for common functionality, examples, and guidelines.
Cyclops
Posts: 4
Joined: Mon Apr 08, 2019 4:34 am

How do I create a repo variable linked to a datasource?

Post by Cyclops » Thu Jun 13, 2019 4:26 am

Howdy,

This doesn't need to change during execution. I just want to be able to run the tests on any domain I need to.

Testing over multiple domains means that I need the 'ApplicationUnderTest' in the repo to be dynamic.
So instead of ApplicationUnderTest /dom[@domain='blah.test.com.au']
I would like ApplicationUnderTest /dom[@domain=$QAUnderTest+'.test.com.au']

I would like to be able to link $QAUnderTest to a datasource I have.

I assume I am going about this the wrong way, but I am sure someone will set me straight!

User avatar
Stub
Posts: 515
Joined: Fri Jul 15, 2016 1:35 pm

Re: How do I create a repo variable linked to a datasource?

Post by Stub » Thu Jun 13, 2019 8:17 am

You can configure that Repository variable via a code module that reads your datasource, if that is appropriate to your scenario. Or if it's a data-driven test that you run across multiple domains, then you can connect a field in the datasource to that Repository variable in the Ranorex UI via the Data Binding tab on a Test Case or Smart Folder.

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

Re: How do I create a repo variable linked to a datasource?

Post by odklizec » Thu Jun 13, 2019 8:30 am

Hi,

You just need to use a 'regex' operator, instead of simple 'equal' operator:
/dom[@domain~$QAUnderTest+'.test.com.au']
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
Franz
Posts: 3
Joined: Fri Jun 21, 2019 3:25 pm

Re: How do I create a repo variable linked to a datasource?

Post by Franz » Fri Jun 21, 2019 4:05 pm

The RxPath you posted is correct for your purpose.

In this case the '$QAUnderTest' is a repository variable, you can bind the variable easily to a datasource that can append on any smartfolder in your testsuite.

Open your testsuite and add your TestModule inside of a SmartFolder, after doing so you should see something like this: Unbound variables: 1 in the datasource column.

Just doubleclick on it and the datasource window should appear where you can bind your variable on any parameter or datasource column.

If you are not in mind to change the domain during execution then i would suggest to use a global parameter instead thats called 'CurrentDomain' and bind it to the 'QAUnderTest' variable. You can change the value of the 'CurrentDomain' parameter anytime.

Otherwise you can use a .csv file to define multiple domains where each row represents the current domain that will be saved in your 'QAUnderTest' Repo Variable.