Bind variable in Code Module to value keysequence

Ranorex Spy, Recorder, and Studio.
Posts: 1
Joined: Thu Aug 01, 2013 7:58 am

Bind variable in Code Module to value keysequence

Post by elzermank » Thu Aug 01, 2013 8:13 am


In the company I work we have a developer (me) and a tester (that does not know any programming languages). So, for testing purposes we want to team-up, so I would do the programming stuff in Ranorex studio and he will make the testcases.

But I have one problem:

I have created a function, in a code module, that gets the response of a webpage. This response is json and the code reads that json to "readable" C# code.
I.e. I get the response { username: something } and my C# code places the value of username in the C# variable Username (string).

When this code is executed, and the variable Username is set, I want to run a recording. In this recording is a keysequence-action with a value "testdata".

What I would like to do:
1. Run the Code Module that sets the variable
2. Run the recording with the variable-data set in previous action

I've tried to add variables in the recording itself and setting those from the Code Module, but when the recording starts, the variable value is set back to the default.
I don't want to touch the usercode of the recording, since I want to reuse the code in Code Module and use the variable in more than one recording.

So, the main goal is to set the variable in a Code Module and use it directly in the recording, without doing any programming.

Is there an example of such a situation?

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Bind variable in Code Module to value keysequence

Post by Support Team » Mon Aug 05, 2013 4:53 pm


In general, you would need to bind your variables (Recording and Code Module) using a data binding.
I recommend to create a 'Global Parameter' and bind it to both of your variables.
Please take a look at our User Guide for more information about Combining Variables with Parameters

Markus (T)