How to call a recording module from a code module

Ask general questions here.
bygones
Posts: 31
Joined: Fri Nov 27, 2015 11:32 am

How to call a recording module from a code module

Post by bygones » Tue Oct 11, 2016 1:02 pm

Hi,

I have a code module, that calls a recording module. As everything was on the same level under the solution, I could simply write in code MyModule.start(). But now I have reorganised my structure and introduced folders, so that the solution is more intuitiv.

Before it was
Solution
   |__ MyModule
   |__ MyCodingModule.cs
and now it is
Solution
   |__ General
            |__ MyModule
            |__ MyCodingModule.cs
When I open MyCodingModule.cs, the reference to MyModule is marked with The name 'MyModule' does not exist in the current context (CS0103).

How do I need to reference the recording module ?

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

Re: How to call a recording module from a code module

Post by odklizec » Tue Oct 11, 2016 1:57 pm

Hi,

I guess by "Folder" you mean a "Test Case"? Because as far as I know, it's not possible to add recording/code modules to a plain folder without enclosing them in a Test Case?

As for calling recording module from code module, it should be enough to call it like this:

Code: Select all

SolutionName.RecordingName.Start();
Once you type SolutionName., Ranorex should offer you a list of available modules you can choose from.

Anyway, I think that calling a recording module directly from code module is not a very good idea. This habit could easily create a very messy and "unreadable" test suite structure? You should use it only when there is absolutely no other way to achieve what you want. Just my opinion ;)
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

bygones
Posts: 31
Joined: Fri Nov 27, 2015 11:32 am

Re: How to call a recording module from a code module

Post by bygones » Mon Oct 17, 2016 7:44 am

odklizec wrote:Hi,

I guess by "Folder" you mean a "Test Case"? Because as far as I know, it's not possible to add recording/code modules to a plain folder without enclosing them in a Test Case?
the recording modules are in one or more test cases. With folder I mean in the solution view on the upper left hand side, I have

Code: Select all

Solution testsolution
 |__ testsolution
        |__ References
        |__ Reports
        |__ General (<--- this is a folder i created by right click on "testsolution" -> "Add" -> "New Folder")
               |___ CheckLoginIsRequired.cs
               |___ LoginWithUser.rxec
So the CheckLoginIsRequired.cs checks, whether the application requires to login or if the user is already logged in. If not, it calls LoginWithUser.
odklizec wrote: As for calling recording module from code module, it should be enough to call it like this:

Code: Select all

SolutionName.RecordingName.Start();
Once you type SolutionName., Ranorex should offer you a list of available modules you can choose from.
ok with that it worked. testsolution.General.LoginWithUser was the key.
odklizec wrote: Anyway, I think that calling a recording module directly from code module is not a very good idea. This habit could easily create a very messy and "unreadable" test suite structure? You should use it only when there is absolutely no other way to achieve what you want. Just my opinion ;)
The idea behind this is that I want/need a conditional. If the current test case requires a login, do so. If not, dont break and proceed. The optimal/normal way is that a test cases starts the application, logs in, test something and log out. If due to whatever reason, the log out fails, I dont want the next test case to fail at the first step, namely to login in.

Darwin
Posts: 26
Joined: Tue Jul 25, 2017 9:00 pm

Re: How to call a recording module from a code module

Post by Darwin » Tue May 01, 2018 7:50 pm

I find myself needing to do this as well. I'm working on some logic for test suite startup, and I've found that I get frequent failures from the WPF process if I make my first calls to the UI from user code instead of from a recording module. I don't want to risk that.

I think what I will be doing so anyone looking at my test cases can understand them is call the user code, add the recording modules to the test case right after the user code call but disable them, and, as always, comment the heck out of them inline and in user code.

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

Re: How to call a recording module from a code module

Post by odklizec » Wed May 02, 2018 7:19 am

Hi,

This post is quite old and does not reflect the actual state of Ranorex. I personally think that calling recording directly from another recording/code module, is still a bad idea. Ranorex currently supports Conditions at TestCase/SmartFolder level. So it's easy to create a TC/SF containing recording/code module(s) of your choice and run them only if certain condition is fulfilled. I would suggest to read about TC/SF conditions >here<.
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