How to convert string to repo item path

Class library usage, coding and language questions.
pksy
Posts: 10
Joined: Fri Dec 16, 2011 7:06 pm

How to convert string to repo item path

Post by pksy » Fri Jan 20, 2012 8: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?

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: How to convert string to repo item path

Post by Support Team » Mon Jan 23, 2012 1: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 ... s.71).aspx
Another possible solution would be so search the button by using the RxPath starting from the container level.

Regards,
Peter
Ranorex Team
.
Image

User avatar
Florent
Posts: 67
Joined: Wed Jul 04, 2012 3:31 pm
Location: Amiens / France

Re: How to convert string to repo item path

Post by Florent » Mon Sep 17, 2012 4:15 pm

ok but, please, in which conditions can we use the following methods ?
ToResolvedString :
http://www.ranorex.com/Documentation/Ra ... String.htm
Implicit :
http://www.ranorex.com/Documentation/Ra ... plicit.htm

Is there a way to use this metods to store the current repository Item path to a variable ?

Thank you in advance
Florent

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: How to convert string to repo item path

Post by Support Team » Mon Sep 17, 2012 5:36 pm

Hello Florent,

I am afraid that these two methods are not able to do what you want. It would be better to use the 'AbsolutePath' property instead.
String btn = repo.Application.ButtonInfo.AbsolutePath.ToString();
Regards,
Bernhard
Ranorex Support Team
.
Image

sham526
Posts: 34
Joined: Wed Jul 07, 2010 7:12 am
Location: Hyderabad(INDIA)

Re: How to convert string to repo item path

Post by sham526 » Tue Sep 18, 2012 6:44 am

U can try the below one also.
String str_btn = repo.Application.ButtonInfo.GetPath.ToString();