UserCodeModule1 Variable not available in subsequent module

Ask general questions here.
craig77
Posts: 7
Joined: Fri Sep 13, 2013 1:52 pm

UserCodeModule1 Variable not available in subsequent module

Post by craig77 » Fri Sep 13, 2013 4:06 pm

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

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

Re: UserCodeModule1 Variable not available in subsequent module

Post by Support Team » Mon Sep 16, 2013 4:55 pm

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
.
Image

craig77
Posts: 7
Joined: Fri Sep 13, 2013 1:52 pm

Re: UserCodeModule1 Variable not available in subsequent module

Post by craig77 » Tue Sep 17, 2013 10:07 am

Thanks Markus, that sorted it.