Hi,
Is there a way to use functions from a library as "usercode" action in a recordmodule, without implementing the functions in the usercode.cs file ?
We like to create librarys with common functions which should be used in several recordmodules. This could be interesting for people who do not develop.
regards,
Kurt
Usercode from library
Re: Usercode from library
Good question! I was thinking about the same on yesterday, while implementing the same function in multiple usercodes, which I think is a prospective nightmare from the maintenance point of view. I'm not a programmer and my C# skills are currently pretty limited. So please don't laugh if it's an easy one 

Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
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
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Usercode from library
Hello,
Yes. You can create your own DLL with your custom functions in Visual Studio.
Just create a new 'Class Library' in Visual Studio, add a few functions and reference it in your test solution.
Regards,
Markus (T)
Yes. You can create your own DLL with your custom functions in Visual Studio.
Just create a new 'Class Library' in Visual Studio, add a few functions and reference it in your test solution.
Regards,
Markus (T)
-
- Posts: 47
- Joined: Tue Sep 06, 2011 7:48 am
Re: Usercode from library
OK,
How can i use the functions of the library directly in the recording module by selection [Add new action] -> [user code] -> [Methode name]. Without writing the same functions from the library in the usercode.cs again.
To avoid duplicate work for every new recordingmodule.
Our goal is to provide a test automation library (dll) which can be used directly in a recording module. This way also non programmers can create new testcases with functions developers provide.
regards,
Kurt
How can i use the functions of the library directly in the recording module by selection [Add new action] -> [user code] -> [Methode name]. Without writing the same functions from the library in the usercode.cs again.
To avoid duplicate work for every new recordingmodule.
Our goal is to provide a test automation library (dll) which can be used directly in a recording module. This way also non programmers can create new testcases with functions developers provide.
regards,
Kurt
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Usercode from library
Hello,
If you extend the recording class you could use methods of your modules of your library within a test suite as shown below:
Regards,
Markus (T)
If you extend the recording class you could use methods of your modules of your library within a test suite as shown below:
public partial class Recording1 : ReportDLL.UserCodeModule1ReportDLL is the name of the DLL and UserCodeModule1 is the class to be used.
Regards,
Markus (T)
Re: Usercode from library
HElP - I am going mad ...???
This is what I have done. VB.NET not C# .
I made a new solution and then added a project (RT-click/add new project/advanced/Ranorex Class Library) called MyLibrary.
Then in the MyNewClass.vb I added a public sub within the class -
Public Class MyNewClass
Public Sub MySub(arg1 as string)
... some code ...
End Sub
End Class
I build this and then close the project/solution.
Open a new solution - MyLibraryTest
add new existing project to add in the project with MyNewClass
add a reference in MyLibraryTest to this project
Now within a recording (e.g. Recording1.usercode.vb ) I add the following -
Public Partial Class recording1 : MyLibrary.MyNewClass
When I try to compile I get invalid End of statement.
I have noticed that if I use Intellisense and type ": MyLibrary." then I get offered a class My which is NOT the full class name.
Please - step by step - tell me what I am doing wrong ...
I want to have functions such as SetVariableTo( variable, value) in a shareable library which I can simply add to recordings using the Add/Usercode and selecting the function from the drop-down.
Many thanks.
orbistest

This is what I have done. VB.NET not C# .
I made a new solution and then added a project (RT-click/add new project/advanced/Ranorex Class Library) called MyLibrary.
Then in the MyNewClass.vb I added a public sub within the class -
Public Class MyNewClass
Public Sub MySub(arg1 as string)
... some code ...
End Sub
End Class
I build this and then close the project/solution.
Open a new solution - MyLibraryTest
add new existing project to add in the project with MyNewClass
add a reference in MyLibraryTest to this project
Now within a recording (e.g. Recording1.usercode.vb ) I add the following -
Public Partial Class recording1 : MyLibrary.MyNewClass
When I try to compile I get invalid End of statement.
I have noticed that if I use Intellisense and type ": MyLibrary." then I get offered a class My which is NOT the full class name.
Please - step by step - tell me what I am doing wrong ...

I want to have functions such as SetVariableTo( variable, value) in a shareable library which I can simply add to recordings using the Add/Usercode and selecting the function from the drop-down.
Many thanks.
orbistest
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Usercode from library
Hello,
The posted code snippet works only in C# (not in VB.NET).
Please use the following code to inherit your library:
Markus (T)
The posted code snippet works only in C# (not in VB.NET).
Please use the following code to inherit your library:
Public Partial Class Recording1 Inherits MyLibrary.MyLibrary.MyNewClassRegards,
Markus (T)