Use of Repository Variables

Class library usage, coding and language questions.
Posts: 20
Joined: Wed Sep 14, 2016 10:55 pm

Use of Repository Variables

Post by annavamsi » Mon Jun 05, 2017 11:40 am


I am currently using repository variables in Ranorex and I have a question

When I update the repository variable it does not get reflected to the correct object.

For example:- say ImageSegment is my repository variable used in ImageSegmentElement.

var myRepo = <RepositoryName>.Instance;
Repo.ImageSegment = "1"
var imageSegment = myRepo.<Someting>.ImageSegmentElement; // goes to correct element
<...Do something.. >
Repo.ImageSegment = "0"
myRepo.<Someting>.ImageSegmentElement; // the change in variable is not reflected goes to previous element.

Are we not supposed to use the variables? How to solve this issue?


Posts: 254
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Re: Use of Repository Variables

Post by Vaughan.Douglas » Mon Jun 05, 2017 4:48 pm

I may have misunderstood your question, so I'm sorry if that's the case. As far as I understand a repository variable is a variable used within the RxPath of a repository item.

So in
var myRepo = <RepositoryName>.Instance;
"myRepo" isn't a "repository variable" it's just a regular old variable in your code.

What is it you're trying to accomplish?
Doug Vaughan

Certified Professional
Certified Professional
Posts: 192
Joined: Fri Sep 07, 2007 8:16 am

Re: Use of Repository Variables

Post by ahoisl » Mon Jun 05, 2017 10:08 pm

I'm not quite sure what your code is doing since you refer to your repository with both "myRepo" and "Repo" without further explanation. However, there is a simple way to check the resolved RanoreXPath of repository items, i.e. the path with its repo variables replaced by their bound values:
Get the AbsolutePath property of a repository item info and then use the ToResolvedString method like in the following example:
var resolvedPath = myRepo.<Something>.ImageSegmentElementInfo.AbsolutePath.ToResolvedString();
Ranorex Team