Variables that share a parameter connection

Ask general questions here.
brentmclauclan
Certified Professional
Certified Professional
Posts: 23
Joined: Wed Jun 25, 2014 11:59 am

Variables that share a parameter connection

Post by brentmclauclan » Fri Jul 11, 2014 12:05 pm

Hi there.

When a several variables are assigned to the same parameter their initial values are replaced with that defined in the parameter (assuming running the test case and not just the module).

Step 1: Create a parameter named dataToAdd and set its value to TEST123

Step2: Assign several module variables to it: var1(moduleA) var2(moduleB)

Step3: In moduleA - add several user code sections: UserCode1 with a message box to show var1 value (shows TEST123), UserCode2 changes var1 to "TESTABCD"

Step4: In module - add user code section: UserCode1 with message box to show var2 (shows TESTABCD).


Observation/Question - is the following statement correct?

The option of binding variables to a common parameter - provides the means to externally modify the module variables (assuming global parameter) - AND - provides the means for variables (located in other modules) to be "linked" where a change made to one bound variable (in one module) is reflected in the other bound variable(s) (in other modules).

Seems to be true - just double checking.

Thanks

Brent

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

Re: Variables that share a parameter connection

Post by krstcs » Fri Jul 11, 2014 1:57 pm

That is correct for parameters. They are designed to be manipulable at runtime just for situations like you described. This is the intended way to pass information between modules (there are other ways, but they involve coding... :D ).

I do this with an INDEX parameter. There are some tables where the only way to identify the row I need is with a piece of data that I can change (the quantity). So, when I change the quantity it invalidates the object and Ranorex can't find it. I have to first find the desired row and set the index in one module, and then later on I use that index in another module to identify the desired row and change it without causing issues.


*** For data connectors, it is a bit more complex. You usually don't need to (and shouldn't) change data from data connectors, but it can be done.
Shortcuts usually aren't...