Start Code module from code modle

Ask general questions here.
mapa
Posts: 22
Joined: Tue Jun 06, 2017 7:29 am

Start Code module from code modle

Post by mapa » Thu Jul 06, 2017 7:09 am

Hi,

how can i start from my codeModule ( m1 ) the codeModule ( m2 )?
normally i just have to create an object of the other module and execute the "run" methode but in this case
it is for some reasons not working...
I hope you cann help me.

BR
Patrick

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

Re: Start Code module from code modle

Post by odklizec » Thu Jul 06, 2017 7:33 am

Hi Patrick,

I think this post should help:
https://www.ranorex.com/forum/how-to-ca ... tml#p12733
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

mapa
Posts: 22
Joined: Tue Jun 06, 2017 7:29 am

Re: Start Code module from code modle

Post by mapa » Thu Jul 06, 2017 9:04 am

yeah... i already saw this and tried it out. So when i have created an instance i am NOT able to select the run() method with it...

i attached a screen
You do not have the required permissions to view the files attached to this post.

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

Re: Start Code module from code modle

Post by odklizec » Thu Jul 06, 2017 9:57 am

That's weird. Are you sure the module in question is a Ranorex code module (with ITestModule.Run() section) and not just a plain class?
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

mapa
Posts: 22
Joined: Tue Jun 06, 2017 7:29 am

Re: Start Code module from code modle

Post by mapa » Thu Jul 06, 2017 9:59 am

strangely, if i put all the stuff which is inside the run method into a new separate method and call this method in the run method. Gladly we are able to call this method from the other code module.
I am not sure if this is the smartest solution...
So if you have any advice for me, let me know it.

Thanks a lot

User avatar
RobinHood42
Posts: 324
Joined: Fri Jan 09, 2015 3:24 pm

Re: Start Code module from code modle

Post by RobinHood42 » Fri Jul 07, 2017 12:58 pm

Hi mapa,

You could do the following:
var us = new  UserCodeModule1();
        	TestModuleRunner.Run(us);
Hope this helps,
Robin 8)

mapa
Posts: 22
Joined: Tue Jun 06, 2017 7:29 am

Re: Start Code module from code modle

Post by mapa » Mon Jul 10, 2017 7:40 am

Thx it is working so far.
The problem is that my datas are not bound anymore when i execute it via the code :|

User avatar
RobinHood42
Posts: 324
Joined: Fri Jan 09, 2015 3:24 pm

Re: Start Code module from code modle

Post by RobinHood42 » Tue Jul 11, 2017 12:59 pm

Hi mapa,

I'm afraid a correct databinding can just be ensured, when executing the whole test suite and not by running or programmatically calling individual modules.

Cheers,
Robin

mapa
Posts: 22
Joined: Tue Jun 06, 2017 7:29 am

Re: Start Code module from code modle

Post by mapa » Tue Jul 25, 2017 9:03 am

is this a planed feature for upcoming versions ?

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

Re: Start Code module from code modle

Post by odklizec » Tue Jul 25, 2017 9:16 am

Hi,

I don't think that there is such feature planned (starting code module from code with binded data connector). But you can always make a feature request (using user voice platform). You see, the data connectors are always bound to TestCase/SmartFolder and starting recording/code module from code is not recommended approach, because it may break the test flow. This is why you should use the test suite.

What you can do is to add the code module into SmartFolder, which you can dynamically enable/disable from code, based of the actual test state. This way you will be sure the code module is properly filled with data from Data Connector and the test flow will be much more straightforward.
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

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Start Code module from code modle

Post by krstcs » Tue Jul 25, 2017 1:39 pm

Yeah, if you call a module from inside another module, then you have to set the values of the inner-modules variables in code, Ranorex doesn't know that you are doing this (and it isn't supported or recommended by the Ranorex team, btw).

I have had to do this before when I needed to reset an SUT after an error in the run (I just wrapped all of the shutdown/startup modules in a single code module with an if() and manually set the values of the variables from the outer-module's bindings).

I would recommend looking at ways to change your approach to the automation before actually trying this because it's a maintenance headache in the long-run.
Shortcuts usually aren't...