Page 1 of 1

Action "Touch": Random element

Posted: Thu Nov 20, 2014 6:16 pm
by cristiandiaz.mirada
Hi,

Is it possible to use "Touch" action so that it selects a different element each time?

Say for example:
//table/container[3]

Where "3" is the ID of one given element I want to "Touch".
Then, having different containers in my application, is there any way I can indicate Ranorex to randomly pick up "3", or "2", or "1" randomly?

A big thank you in advance.

Re: Action "Touch": Random element

Posted: Fri Nov 21, 2014 11:30 am
by Support Team
Hello,

You will need to create a UserCodeMethod in order to achieve the mentioned behavior.

For example:
Table table = "/table[...]";

IList<Container> myList =  table.FindDescendants<Container>();

//Create new Random number
Random r = new Random();
int random = r.Next(myList.Count -1);

//Touch random entry
myList[random].Touch();
Regards,
Robert