Page 1 of 1

Use varaibles to access objects??

Posted: Fri Jul 02, 2010 3:18 pm
by lazy9669
Is it possible to use a variable in an objects path when I'm trying to access it?

In the below example I have a dynamic table with rows named Row011 to Row0x1, where x can vary. I'm trying to make a for loop that will go through all rows, 1 to x and click them.
int i;
Accessible repopath;
			
for(i = 1; i <= Variables.NumRows; i++)
{
    Report.Info("Turning on Link " + i);
    repopath = "repo.FormSM.Row0" + i + "1.Cell";
    repopath.Click();
}
I receive the following error when trying to run this code:
Ranorex.RxPathException: Invalid RxPath 'repo.FormSM.Row011.Cell'. ---> Ranorex.RxPathException: Invalid character at character position 4.
at Ranorex.Core.RxPath..ctor
at Ranorex.Core.Element.op_Implicit
at Ranorex.Accessible.op_Implicit

Is there a way to use different variables in order to access objects? I also have another instance where I'd link to use a string variable in the objects path.

Re: Use varaibles to access objects??

Posted: Mon Jul 05, 2010 10:37 am
by Support Team
Hi,
lazy9669 wrote:Is it possible to use a variable in an objects path when I'm trying to access it?
Please read following post
http://www.ranorex.com/forum/looping-th ... t1347.html
If you adapt this code a little bit, it should work for your solution.

Please also take a look to our screencasts about the RxPath
http://www.ranorex.com/support/screencasts.html

Regards,
Peter
Ranorex Support Team