Passing variables' values to nested recording module

Ranorex Spy, Recorder, and Studio.
David Zita
Posts: 14
Joined: Thu Mar 31, 2016 1:20 pm

Passing variables' values to nested recording module

Post by David Zita » Thu Mar 31, 2016 1:29 pm

I have one main recording module that has several variables set. Values of these variables may vary so they are set every time the test suite is run (so I cannot use default values). Now, in this main recording module, I have a place where, based on one of the variable's value, I decide, which of the child module will be called. I call the child modules as RecordingModule.Start(). And there i need to somehow pass the values of the variables. These values are stored in Global variables, then passed to the main module when the particular test case is called. But how do I pass them to next module? I tried something like MainModule.Instance.variable1 calling from the child module but it does not work.
Thanks
David

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

Re: Passing variables' values to nested recording module

Post by odklizec » Fri Apr 01, 2016 8:17 am

Hi David,

Could you please post an example solution or at least post a picture of your test suite structure?

In my opinion, the best way of passing variables to nested modules is using data connectors and binding variable as needed? Eventually, use Test Case parameters, which you can fill anytime and from any recording module belonging to that test case. So all you need to do is to connect the data connector/TC parameters to expected module variables.

I would strongly discourage from passing variables between modules directly from code, because this could cause a mess in a long run and make the reusability of modules pretty hard if not impossible.
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

David Zita
Posts: 14
Joined: Thu Mar 31, 2016 1:20 pm

Re: Passing variables' values to nested recording module

Post by David Zita » Fri Apr 01, 2016 8:42 am

I made a small example. There is one global variable (var1), that is bound to module variable (MainVar) of the module Main. In the user code of Main module I call the Child1 module and there I write out child1var and also click on a button in WinCalculator that is defined using this variable (child1var). The current solution works, I set the child1var before I call the child1.Start() method. If you have better solution, bring it on. The databinding and data connectors don't work because the child1 module is not present at all in the TestCase.
Regards
Attachments
Variables.zip
(30.68 KiB) Downloaded 57 times

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

Re: Passing variables' values to nested recording module

Post by odklizec » Fri Apr 01, 2016 10:10 am

Hi,

I'm sorry for saying this, but in my opinion, this is entirely bad design. You should never call the recording modules from code like this. From a long run perspective, this is unsustainable and very messy test design. Even from this simple example it's not quite clear to me what exactly you want to achieve? You should always have all your test case modules in solution so then you can bind variables to data connectors and run/skip modules(TCs) based of certain conditions.

If you want to run or skip some modules based of a variable/parameter value, you should use something like I described here:
http://www.ranorex.com/forum/how-to-con ... tml#p36500
It's not perfect solution either, but it's probably best what we currently have.

BTW, it seems Ranorex folks currently working on a support for conditional execution of modules:
http://www.ranorex.com/company/product-roadmap.html

Hope this helps?
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

David Zita
Posts: 14
Joined: Thu Mar 31, 2016 1:20 pm

Re: Passing variables' values to nested recording module

Post by David Zita » Fri Apr 01, 2016 12:01 pm

Hi,

thanks for the post. I feel I need to clarify few things. First, the example I gave you was only to show how the passing of variables (doesn't) work. In my real example, I have a module that handles filling of some form. One of the first item on this form is combo-box and based on its value the whole rest of the form changes. So my thoughts were: "ok, I can make separate module for each individual case and just call it according to this 'combo-box' variable value". I don't think it's a bad design, and it could have worked great if only Ranorex had already the conditional execution of modules done :) Since I have to deal with the condition by myself, I came with what I have posted before. But your example does not look so bad either. I would basically have one main module and then several (like 6) modules, on the same level, right? All of them would be disabled by default and I would then enable only the one that would be needed, from within the code of the first module. I might try that, so thanks again.