Page 1 of 1

Problems with Variables

Posted: Wed Apr 08, 2015 12:31 pm
by Karlsruhe87
Hello,

I'm new to ranorex and got a certain problem with variables.
For a testcase, I try to extract the version of our software from the titlebar, save it as variable and use it with further tests.

My first try was a simple module which extract the title (String), search for the Version-Number (via Regex) and convert it to integer for further usage.
This method works, but only inside of the module. It would be a lot better to have access to the version-variable on a higher level.

So I went on and searched for a method, so I extract the variable and make it possible to access it from another module - no success here. How can I do this?

Another thing I wondered: Via the Action GetValue in a module it is possible to extract some certain value and bind it to a variable. In my case the Item is the
TitleBar, but I only need the first number in the titlebar bound to the variable. Like I described it above, I used usercode to bind this to the variable - but is
there a faster way? Directly with Regex on the Element?

And if I code a method with a resulttype (so not void), how can I bind this result to a variable?

Thanks for the help.

Regards from Karlsruhe

Operating System: Local, Win7 64bit
Ranorex 5.3.1-22939

Re: Problems with Variables

Posted: Wed Apr 08, 2015 12:45 pm
by odklizec
Hi,

This blog post might help you...
http://www.ranorex.com/blog/sharing-dat ... to-another

Re: Problems with Variables

Posted: Thu Apr 09, 2015 7:50 am
by Karlsruhe87
Thanks, that helps with variables in other modules.

And how do I bind the result of a variable in a usercode-Action to a variable in the module?

Re: Problems with Variables

Posted: Thu Apr 09, 2015 8:01 am
by odklizec
Hi,

To bind user code variable to module variable, simply assign the module variable with user code variable, like this...

Code: Select all

moduleVar = userCodeVar;
Where moduleVar is your Module variable. Once you start typing the module variable name (in module usercode), it should get listed in the code-completion list of available methods, variables, parameters, etc...