Page 1 of 1

Making Classes available in Recording Editor

Posted: Sat Aug 17, 2019 12:04 am
by somguy
Hi,

I'm working in a team using Ranorex to test a windows application. I would like to write a class for our tests that is essentially this:
public class User
{
   string name;
   string password;
   string role;

   public bool LogIn() { //do login }
   public bool ChangePassword(string NewPassword) { //change password}

   public User( string, string, string){}
}
I know how to do this in UserCode, but I would like to make this accessible to the Recordings such that someone can create new action > user code > UserInstance.LogIn();

Is this possible, if so how would I go about doing this?

Thanks in advance!

Re: Making Classes available in Recording Editor

Posted: Mon Aug 19, 2019 12:02 pm
by odklizec
Hi,

The best you can probably do is to create and use User Code Collection, which you can use both in code modules and recordings (via User Code action). Please check this user guide chapter and eventually, search this forum for some examples and other related posts...
https://www.ranorex.com/help/latest/ran ... roduction/

Re: Making Classes available in Recording Editor

Posted: Tue Aug 20, 2019 2:03 am
by somguy
Thanks for the reply odklizec,

I have tried using a Code Collection, but as far as I understand I am limited to providing static methods. I am (as I imagine most are) working on a team with a lot of tests, and occasionally we have temps work with us. For temps there is no guarantee of experience with coding, so the use of Recording Editor is often a more productive interface for them.

However, at the same time we are trying to build a library with core functionalities readily available for everyone. To this end I would like to take advantage of OO's classes in the Recording Editor. The functionality seems to be there already, for example being able to drag and drop repository items and calling specific functions for those adapters, so I was hoping there might be a way to do something similar with our own classes.

I tried creating a factory method, but the Recorder treated the return as a void that I could not (at least not as far as I could tell) assign to a variable. My next attempt will probably be a Code Collection that uses my class and a static dictionary, but if anyone has a better solution it would be very appreciated!