Page 1 of 1

Dynamically Changing the Repo Paths

Posted: Wed Apr 29, 2015 12:22 pm
by jrob3rts
I'm using Ranorex 5.2.2.
I have currently got 3 repo items which use repo variables. I assign values to these variables on the fly to suit the test needs. One of these is the root folder (used to specify the domain) and the other two are items within the repository used for tests we have built so far.

When I review the test suite, each test is marked as an unbound variable (presumably because it's not been assigned as yet). I find this annoying and doesn't allow me to identify actual unbound variables easily. I have seen a suggestion of applying a dummy global variable to these, but am looking for another solution.

So, can I remove a path from a Repo item (leaving it empty / base), and therefore remove the variable and then assign the path within my code as part of my startup / setup script? I believe this would remove the unbound issue.

I have tried, but failed miserable, receiving a ".....read only" type response.

Any assistance would be appreciated.

Thanks

James

Re: Dynamically Changing the Repo Paths

Posted: Wed Apr 29, 2015 4:37 pm
by krstcs
Can you provide a bit more information, specifically the XPath you are using (including variables and values)? Also, if you could post the Ranorex solution (or a sample that demonstrates the problem) it would help.

Variables must have data bound to them or they will use the default value. If that is what you want, then you can turn off warnings about unbound variables by right-clicking the test case and selecting 'Properties'. There is a setting in the properties window that allows you to turn off the warning test case-by-test case.

I would caution doing this however as variables are MEANT to be bound, in order for Ranorex to know what values to pass to it at runtime. This is what binding is. The warnings are there to let you know that you aren't passing values to a specific variable. You should either bind it to the correct data column or to a parameter (global or test-case) so that you know it is being passed the correct values at runtime.

It is also much easier in the long run to bind variables to global parameters so that you only have to change the value once, in one place, instead of having to go to each place the variable is used and change it.

Re: Dynamically Changing the Repo Paths

Posted: Fri May 15, 2015 8:21 am
by jrob3rts
Hi,
Apologies for the delay here.

I've turned off the warning regarding unbound variables. I do however continue to see them in the Test Suite viewer. (See Attachment)

I suppose I generally have 3 Variables which I am using within the Repo. One being the Domain, an other being the URL passed and another one that escapes me for now. We run our tests across various domains and I am hoping not to need to open Ranorex Studio to set this for each execution, so I will be passing or pulling the values from a data source as part of the execution.

I have attached an example of the Repo Variable for clarity. I would like to have this as 'Nothing' as an example, and then dynamically change the path to suit the location that I am running the test from.

I hope that's clearer.

Re: Dynamically Changing the Repo Paths

Posted: Fri May 15, 2015 2:41 pm
by krstcs
Can you explain why you don't want to bind the variables?

The issues is, as I said, that Ranorex expects the variables to be bound to some data source, whether it's a parameter (global or test case) or a data set (Excel sheet, DB query, CSV file). If you don't bind the variables then the default value is always used and you will always see the warnings in the test suite (this cannot be turned off, only the report warnings are turned of by the setting).

You should be binding all variables.

If you want to bind them to a command-line parameter you can bind them to the Global Parameters and then pass the desired value in at run-time.

Please read the user guide, it explains variables and parameters very well.

http://www.ranorex.com/support/user-guide-20.html

Re: Dynamically Changing the Repo Paths

Posted: Mon May 18, 2015 4:08 pm
by jrob3rts
Hi,
Thanks for your response. From my point of view, I found it annoying to have to rebind Repo variables if I added a new one, or in a similar circumstance. I also had an annoying issue recently where a Test variable existed and was over-riding the value I applied to the variable.

Some of my repo variables are dynamically generated at runtime, therefore no static 'correct' variable can be applied before the test if within it's execution stage.

Fundamentally, not the end of the world and if I could do what I wanted to do, then it would be easier on the eye. If not, then I will go down the route of looking to bind variables of nothing and then set them dynamically. However it would be easier to spot a real unbound variable, rather then one which is set within the scripting.

Regards


James

Re: Dynamically Changing the Repo Paths

Posted: Mon May 18, 2015 4:37 pm
by krstcs
Ranorex is designed to use variables that are STATIC from creation, the variable name needs to be the same for each run. The data value stored in the variable can change, but the variable name should not. This is the only way to get binding to work correctly consistently.

Can you explain why you chose to go outside this paradigm and are creating variables dynamically? I'm not sure I see any reason to do it, but if you could help me understand what you are trying to achieve, or why you are doing it, I might be able to help more.


Other than that, I would recommend reworking your tests to be simpler so as not to need to dynamically create variables. Just pass in the data you need at runtime to a static created variable is all you should really need. You can make the same variable mean different things at different times if you handle them correctly. They are all strings when they get to the repo XPath anyway.

But, again, maybe I'm missing something in translation. :D