Variable value not updating when running test

Ranorex Studio, Spy, Recorder, and Driver.
Stu B
Posts: 5
Joined: Fri Oct 21, 2011 2:17 pm

Variable value not updating when running test

Post by Stu B » Wed Aug 15, 2012 1:26 pm

In a recording I have added a variable:
Name Value
Var#1 Form Title One

I use this in an objects path to validate that a form title bar is displaying the correct text:
Object Path
Titlebar titlebar[@accessiblerole='TitleBar' and @text=$Var#1]

Now I have updated my application form title to Form Title Two so I change Var#1:
Name Value
Var#1 Form Title Two

When I select highlight to find the object it fails, the value it is looking for is still:
titlebar[@accessiblerole='TitleBar' and @text='Form Title One']

I can verify the path contains the correct variable - if i edit the variable Var#1 and change it to Var#2 then the value in the object path is automatically updated to titlebar[@accessiblerole='TitleBar' and @text=$Var#2]

but it still keeps searching for "Form Title One" instead of the variables new value which is "Form Title Two"
(when it is searching for the object I look at the tooltip on the searching for elements popup)

Can you point out what I am doing wrong to update the variable value please?

thanks

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

Re: Variable value not updating when running test

Post by krstcs » Wed Aug 15, 2012 1:42 pm

Stu,

I would recommend not using symbols ("#") in your variable names as this may be interpreted incorrectly by the compiler and could cause your assignments to fail.

Try changing the variable name to something without a symbol (i.e. "Var1") and see if that helps.

Also, variable names should be descriptive of what they are holding. In your case a better name might be "titleBarText", for example. :D

Finally, "Var" is a key word in .NET and should not be used for naming variables.

Hope that helps a bit.
Shortcuts usually aren't...

Stu B
Posts: 5
Joined: Fri Oct 21, 2011 2:17 pm

Re: Variable value not updating when running test

Post by Stu B » Wed Aug 15, 2012 2:11 pm

Hi krstcs,

thanks for having a look at that and replying.

I should have stated that the variable names and values I have shown are just examples and my actual names & values do reflect the object.

a better example would read:

Original application form title and variable:
VariableName Value
Version FormTitleOne

change form title in application and update variable:
VariableName Value
Version FormTitleTwo

Object path is:
[@accessiblerole='TitleBar' and @text=$Version]

Highlight object:
object not found - search string is:
titlebar[@accessiblerole='TitleBar' and @text='FormTitleOne']

regards

Stu