Page 1 of 1

Custom Action by Inheritance

Posted: Tue Jun 16, 2015 6:45 pm
by narmand
I followed the steps on this url (http://www.ranorex.com/blog/custom-smart-actions) to link a class to my recording module. When i initially followed the steps it didnt work, I tried on another sample project and it worked, so I decided to try again on my "real" and this time it didnt work. Work as in I could not view the methods on the recording module when I added a user code item to the script. The drop down was empty.

This is what I did:
1) Project, create a C# class
2) pasted my method to the class
3) open the <RecordingName>.UserCode.cs file and add a colon followed by the name of the base class to the existing declaration of the class
4) Added a recording module
5) insert a user code, nothing appears in the drop down
6) created a new recording module and nothing happens
What is the proper sequence ? Do i need to create the recording module first?

Re: Custom Action by Inheritance

Posted: Wed Jun 17, 2015 7:17 am
by odklizec
Hi,

Do you have, by any chance, the class file stored in a folder? In this case, the class name must be preceded with that folder name!
ClassInheritance.png
What happens, if you start typing after the colon? Do you see the class name in IntelliSense popup screen?

Re: Custom Action by Inheritance

Posted: Wed Oct 19, 2016 9:33 pm
by alexpayne
I know this thread is a year old, but I ran in to the exact same problem and thought I could offer some insight for anyone coming after me.
In my case, the issue was that one of the parameters had the type Ranorex.Element. I changed it to Ranorex.Adapter and it worked.

I guess there are some object types that Ranorex won't let you use for parameters.

Re: Custom Action by Inheritance

Posted: Fri Oct 21, 2016 9:21 am
by odklizec
If you want to pass a repo element to custom method, it must be declared either as "repoiteminfo" (Ranorex.Core.Repository.RepoItemInfo) or "adapter" (Ranorex.Adapter).