Hi,
I have test cases with recording modules. I also have usercode files with functions that I need to call from recording modules.
How I can call them please?
How to call function from Recording Module?
- Support Team
- Site Admin
- Posts: 12167
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
Re: How to call function from Recording Module?
Hi,
The UserCodeModules and the Recording files are normal C# classes, so you can call their methods like
you would call them if you have “normal” C# classes.
You can create static methods in your UserCodeModule, then you won’t need an instance of it in the Recording or you can create "normal" public methods then you would need at first an instance of the UserCodeModule.
In your Recording file you can call the specific methods like these:
I would suggest you to use static methods.
Regards,
Markus
Ranorex Support Team
The UserCodeModules and the Recording files are normal C# classes, so you can call their methods like
you would call them if you have “normal” C# classes.
You can create static methods in your UserCodeModule, then you won’t need an instance of it in the Recording or you can create "normal" public methods then you would need at first an instance of the UserCodeModule.
In your Recording file you can call the specific methods like these:
Code: Select all
TestCodeModule.testMethod();
TestCodeModule testModule = new TestCodeModule();
testModule.testMethod2();
The two methods in the TestCodeModule class:
public static void testMethod(){
System.Console.WriteLine("!!!!! UserCode !!!!");
}
public void testMethod2(){
System.Console.WriteLine("!!!!! UserCode !!!!");
}
Regards,
Markus
Ranorex Support Team
Re: How to call function from Recording Module?
Hi Marcus,
Thank you for your help. However, I cannot save any code in recording module - it disapears right after I move to another file - even if I saved it before.
Thank you for your help. However, I cannot save any code in recording module - it disapears right after I move to another file - even if I saved it before.
- Support Team
- Site Admin
- Posts: 12167
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
Re: How to call function from Recording Module?
You cannot change the code in the "Recording.cs" file, only in the "Recording.UserCode.cs" file. The code for the "Recording.cs" file is regenerated every time the recording changes. Please, read following section in the Ranorex User Guide:
http://www.ranorex.com/support/user-gui ... tions.html
Regards,
Alex
Ranorex Team
http://www.ranorex.com/support/user-gui ... tions.html
Regards,
Alex
Ranorex Team
Re: How to call function from Recording Module?
So, again... If I cannot save recoding.cs how I can call it from recording file? Should I move recording.cs to usercode.cs and disabled recording module?
- Support Team
- Site Admin
- Posts: 12167
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
Re: How to call function from Recording Module?
Just add a User Code Action to the recording (using the recorder UI) and then you can use the code Markus posted in that User Code Action. It is documented quite detailed in the User Guide section I already posted before:
http://www.ranorex.com/support/user-gui ... tions.html
Regards,
Alex
Ranorex Team
http://www.ranorex.com/support/user-gui ... tions.html
Regards,
Alex
Ranorex Team