How to convert string to repo item path : Automation API

How to convert string to repo item path

Class library usage, coding and language questions.

How to convert string to repo item path

Postby pksy » Fri Jan 20, 2012 9:10 pm

Hi, I don't know if the following is even possible but here goes:

I have the following repository structure

myContainer -> myButton1
-> myButton2
-> myButton3

I was hoping to pass in a string into a method, where the string is the name of the repo item in the repository, then use it as a repo path and call method.

So my method would be like this:

public void clickButton(string buttonName)
{
myCcontainer.buttonName.Click();
}

And I was hoping to call the method like this:

clickButton(myButton1);

Is there a way to do this?
pksy
 
Posts: 10
Joined: Fri Dec 16, 2011 8:06 pm

Re: How to convert string to repo item path

Postby Support Team » Mon Jan 23, 2012 2:19 pm

Hi,
pksy wrote:Is there a way to do this?

To access the repository elements you have to use .Net Reflection. Currently Ranorex doesn't provide a direct way to access the repo elements as you want to access it.
Reflection Overview:
http://msdn.microsoft.com/en-us/library ... sy(v=vs.71).aspx
Another possible solution would be so search the button by using the RxPath starting from the container level.

Regards,
Peter
Ranorex Team
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria


Return to Automation API

Who is online

Users browsing this forum: No registered users and 0 guests