Bounding a variable causes an error

Ranorex Spy, Recorder, and Studio.
AccidentReport
Posts: 76
Joined: Tue Dec 04, 2012 2:30 pm

Bounding a variable causes an error

Post by AccidentReport » Thu Mar 06, 2014 10:44 am

I have encountered a strange issue and I'm not entirely sure of the reason for it. To make sense of it, first a bit of background.

The tests which I have been building are designed to run on multiple servers testing various stages of the development and deployment process. Therefore one of the early things I did was change the base path of the parent object in the repository to use a variable instead of a fixed URL. It went from "/dom[@domain='www.testbox.co.uk' and @state='complete']" to "/dom[@domain=$testdomain and @state='complete']". So this way I can run it from any box. Overtime I have recorded additional actions and forgot to change this variable back to the path so I do have multiple base objects in the repository but I always change them to use the variable instead of the URL. One day I'll tidy those up.

Now, as you can see in the picture below the module 'FC_Select_DialledNumber' has one bound and one unbound variable. The bound variable is the dialled number which I am selecting and the unbound variable is the testdomain. The module itself now only contains a User Code action which contains the recorded actions surrounded with a bit of intelligence. hence why the module thinks it wants the testdomain bound as it's using repository items such as: repo.website.mainlist.

If I run it as it currently stands it all appears to work correctly. I have even tried running it on muliple servers so the testdomain is different and again, no problem. This issue arrises if I try to bind the variable. When I do that I get an error that states:
Failed to set value 'www.testbox.co.uk' to variable 'testdomain'.
Field or property not found or not writeable.
Does anyone have any idea for why this behaviour is occuring and if there is a way to resolve it? Like I say, it appears to work if it is unbound but it looks untidy!
Attachments
test_structure.png
Structure of my tests showing the 1 Unbound variable
test_structure.png (24.04 KiB) Viewed 1294 times

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Bounding a variable causes an error

Post by krstcs » Thu Mar 06, 2014 2:27 pm

What version of Ranorex are you using?

Is there user code in the module in question? If so, does the user code make use of the variable in question?

Can you post a copy of the project? We might be able to see the issue better.
Shortcuts usually aren't...

AccidentReport
Posts: 76
Joined: Tue Dec 04, 2012 2:30 pm

Re: Bounding a variable causes an error

Post by AccidentReport » Thu Mar 06, 2014 2:36 pm

krstcs wrote:What version of Ranorex are you using?
4.1.1
krstcs wrote:Is there user code in the module in question?
No offence but I did say that the module in question is ONLY user code
krstcs wrote:If so, does the user code make use of the variable in question?
Not directly. Again, as said above, the module is using a repo item, the path of whioch has that variable in it.
krstcs wrote:Can you post a copy of the project? We might be able to see the issue better.
Not publicly due to the security restirctions at the company.

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Bounding a variable causes an error

Post by krstcs » Thu Mar 06, 2014 2:53 pm

Sorry, I read it, but somehow completely missed the user-code part.

You could look through the code files in a plain-old text editor and search for the strings (variable name, etc.) in question. Make the appropriate changes there and then reopen it in Studio.

You could also remove all references to the repo object and variable and then attempt to re-add them to the module. This might force Ranorex to update the module variables.

I would also recommend upgrading to a newer version and seeing if that helps. I saw similar issues a few times with older versions when there is a repository item in user code. It didn't always update correctly when there were changes to the repository.
Shortcuts usually aren't...

AccidentReport
Posts: 76
Joined: Tue Dec 04, 2012 2:30 pm

Re: Bounding a variable causes an error

Post by AccidentReport » Thu Mar 06, 2014 3:05 pm

No worries.

The weird bit is that it correctly recognises that a variable is not bound but binding it causes the error. I have created a new module and retyped the whole code block in from scratch and the same thing occurs. The variable name is not used at any point in the code.

As for an upgrade...currently evaluating the new v5 but will take me a week or two to get round to it and get it approved.