How to bind item path to two different variables?

Best practices, code snippets for common functionality, examples, and guidelines.
Kamil Grabiec
Posts: 3
Joined: Wed Apr 25, 2018 12:21 pm

How to bind item path to two different variables?

Post by Kamil Grabiec » Wed Apr 25, 2018 12:40 pm

Hi, I'm new user of Ranorex 8.0.1 and got a problem.

Let's says I have an app that have two input fields, animal and plant.
If you pass at field animal value "dog" then item with class=dog appeard.
I storage animals at var1 and plants at var2.

At my Test suit I have folowing construction:

Smart Folder:
TC #1:
key sequence "var1" //input[@class=animal]
validation exist //item[@class=dog]
TC #2:
key sequence "var2" //input[@class=plant]
validation exist //item[@class=tree]

But I don't like to create seperate items for every point of validation. I like to have just one item to valid and change his class exp by parameter to have something like this:

Smart Folder:
TC #1: bind parameter with var1
key sequence "var1" //input[@class=animal]
validation exist //item[@class=$parameter]

TC #2: bind parameter with var2
key sequence "var2" //input[@class=plant]
validation exist //item[@class=$parameter]

Is something like this possible?

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

Re: How to bind item path to two different variables?

Post by odklizec » Thu Apr 26, 2018 7:48 am

Hi,

Yeah, this is of course possible. You just have to create two data connectors and each of them must be associated with each own smart folder. Eventually, you can create just one data conenctor, but with two columns. But in this case, each column must have its own name (e.g. "animals" and "plants") and then you must bind the variable to each column manually (e.g. in 1st smart folder to "animal" and in 2nd smart folder to "plants"). In other words, you will not be able to use Auto-Bind feature, which expects the same name for column and module variable. Hope this helps?
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

Kamil Grabiec
Posts: 3
Joined: Wed Apr 25, 2018 12:21 pm

Re: How to bind item path to two different variables?

Post by Kamil Grabiec » Thu Apr 26, 2018 9:46 am

That fil my needs. Thank you for fast respond.