Page 1 of 1

UserCodeModule1 Variable not available in subsequent module

Posted: Fri Sep 13, 2013 4:06 pm
by craig77
I've just started working with Ranorex and I'm having some problems with Module Variables.

I've created a UserCodeModule to extract some data from an Excel spreadsheet depending on which test case is currently being executed. I've followed the steps in the user guide and the declaration in my module is as follows:

Dim _NewVariable As String = "abc"
<TestVariable("474F0059-E679-471F-86F8-1CEB42D0D9AE")> _
Public Property NewVariable As String
Get
Return _NewVariable
End Get
Set(ByVal value As String)
_NewVariable = value
End Set
End Property

I believe I have correctly bound the variables in UserCodeModule1 and the subsequent RecordingModule to a global parameter, and have set the required step in the RecordingModule to use the variable to enter some text into a username field, however when I execute the test case it runs but does enter the value (in this example, 'abc') into the field.

From reading the User Guide I thought I might need to use the setter method, eg:

' Additionally set the Repository Variable in Setter-Method
MyRepo.NewVariable = _NewVariable

and also add the following line as per User Guide:

Dim MyRepo As MyGlobalTestRepository = MyGlobalTestRepository.Instance

However, now when I try to execute the Test Case I get the following error when it is trying to build:

'NewVariable' is not a member of 'GlobalTest.GlobalTest.MyGlobalTestRepository'. (BC30456)

Can any shed some light on this please as it's starting to get very frustrating!

Regards

Re: UserCodeModule1 Variable not available in subsequent module

Posted: Mon Sep 16, 2013 4:55 pm
by Support Team
Hi Craig,

It looks like as if you forgot to create a repository variable 'NewVariable'.

I would recommend to open your repository and click on 'Variables...' in order to create a new repository variable.
Then, you could use your variable with 'MyRepo.NewVariable.

Regards,
Markus

Re: UserCodeModule1 Variable not available in subsequent module

Posted: Tue Sep 17, 2013 10:07 am
by craig77
Thanks Markus, that sorted it.