Problems with Variables

Ask general questions here.
Karlsruhe87
Posts: 8
Joined: Wed Apr 08, 2015 12:26 pm

Problems with Variables

Post by Karlsruhe87 » Wed Apr 08, 2015 12:31 pm

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

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3945
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Problems with Variables

Post by odklizec » Wed Apr 08, 2015 12:45 pm

Hi,

This blog post might help you...
http://www.ranorex.com/blog/sharing-dat ... to-another
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Karlsruhe87
Posts: 8
Joined: Wed Apr 08, 2015 12:26 pm

Re: Problems with Variables

Post by Karlsruhe87 » Thu Apr 09, 2015 7:50 am

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?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3945
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Problems with Variables

Post by odklizec » Thu Apr 09, 2015 8:01 am

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...
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration