Making Classes available in Recording Editor

Ranorex Studio, Spy, Recorder, and Driver.
somguy
Posts: 2
Joined: Fri Aug 16, 2019 11:47 pm

Making Classes available in Recording Editor

Post by somguy » Sat Aug 17, 2019 12:04 am

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!

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Making Classes available in Recording Editor

Post by odklizec » Mon Aug 19, 2019 12:02 pm

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/
Pavel Kudrys
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

somguy
Posts: 2
Joined: Fri Aug 16, 2019 11:47 pm

Re: Making Classes available in Recording Editor

Post by somguy » Tue Aug 20, 2019 2:03 am

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!