Global parameters - recordings' variables binding : General Questions

Global parameters - recordings' variables binding

Ask general questions here.

Global parameters - recordings' variables binding

Postby dman » Tue Sep 13, 2011 5:23 pm

it's described pretty clear ("Lesson 3") how to "combine" them but... what exactly does that mean? does the binding have one direction? I'm asking because I created a global parameter and gave it a value, after wich I created a variable for a recording and performed the binding in a testcase - as I ran the TC, the variable was empty... am I missing some small print somewhere?

All the best!
D.
dman
 
Posts: 24
Joined: Mon Aug 29, 2011 10:33 am
Location: München

Re: Global parameters - recordings' variables binding

Postby Support Team » Wed Sep 14, 2011 12:49 pm

Hi,

As the global parameters are set/saved in the Test Suite file you have to execute the whole Test Suite, otherwise Ranorex is not able to get the values of the global parameters out of the Test Suite.

Regards,
Markus
Ranorex Support Team
User avatar
Support Team
Site Admin
 
Posts: 4843
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: Global parameters - recordings' variables binding

Postby dman » Wed Sep 14, 2011 1:31 pm

Hi Markus,

Thank you for the reply. Indeed, when running the suite, the bound variable gets the parameter's value. Your remark should be emphasized in the documentation.

What about the binding’s direction? What happens if I modify (in code) a variable (bound to a parameter)? What happens if I modify (in code) a parameter (is this possible?) to which a variable was bound?

All the best,
D.
dman
 
Posts: 24
Joined: Mon Aug 29, 2011 10:33 am
Location: München

Re: Global parameters - recordings' variables binding

Postby Support Team » Wed Sep 14, 2011 4:21 pm

Hi,

What happens if I modify (in code) a variable (bound to a parameter)?

As module variables are normal properties you can also use them like properties. That means if you set the variable to another value (in code at runtime) the new value will be taken instead of the value of the global parameter.
What happens if I modify (in code) a parameter (is this possible?) to which a variable was bound?

This is possible but not recommended.
You can set or create global parameters at runtime, but you have to make it before the specific TestCase, where you have bound the variables, is called.

TestSuite.Current.Parameters.Add("GlobalParam3", "30"); //creates a new one
            TestSuite.Current.Parameters["GlobalParam2"]="30"; //overrides the parameter with the specific name
            var testSuite = (TestSuite)TestSuite.Current;
            var testCase = (TestCase)TestSuite.Current.GetTestCase("TestCase");
            var testSuiteModule = testCase.AllModules[0]; // the first module from the specific test case
            testSuiteModule.AddDataBinding(new ModuleVarItem("variable1", new Guid("07bef6aa-2cd3-4ac5-92de-ae42bc078ccf"), "Recording1", ""),
            new ParameterDataBindingInfo("GlobalParam3", 
            testSuite.TestSuiteEntry.Id.ToString(), (TestCase)TestCase.Current));// the new data binding, variable1 is the variable from the specific recording


Kind Regards,
Markus
Ranorex Support Team
User avatar
Support Team
Site Admin
 
Posts: 4843
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: Global parameters - recordings' variables binding

Postby dman » Wed Sep 14, 2011 4:44 pm

Support Team wrote: ... That means if you set the variable to another value (in code at runtime) the new value will be taken instead of the value of the global parameter.

Does this mean that binding is just an initialization (of the variable with the global parameter's value)?

The second part of your answer is unfortunately of no help to me.

My problem: I have a solution, with multiple projects (and hence multiple repositories). There are certain solution-relevant values which I set as "global parameters" (I would only need to read them, though writing would also help). I can do the global parameter - recording variable binding (which works just fine) but I'd have to create a variable every time I need a global parameter - not quite optimal.

Long story, short: what I basically need is a way to globally access some information/variables.


All the best!
D.
dman
 
Posts: 24
Joined: Mon Aug 29, 2011 10:33 am
Location: München

Re: Global parameters - recordings' variables binding

Postby Support Team » Thu Sep 15, 2011 10:20 am

Hi,

Long story, short: what I basically need is a way to globally access some information/variables.

There are more ways to handle this, you can generate a C# Code file (static class or normal public as you like) where you can collect all your "global" parameters or you can directly access the "Ranorex global parameters" through this code:
IDictionary<string, string> idict = TestSuite.Current.Parameters;


Regards,
Markus
Ranorex Support Team
User avatar
Support Team
Site Admin
 
Posts: 4843
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: Global parameters - recordings' variables binding

Postby dman » Thu Sep 15, 2011 10:52 am

Brilliant! Exactly what I needed :D

Thank you!
D.
dman
 
Posts: 24
Joined: Mon Aug 29, 2011 10:33 am
Location: München

Re: Global parameters - recordings' variables binding

Postby slavikf » Thu Sep 15, 2011 5:26 pm

There are more ways to handle this, you can generate a C# Code file (static class or normal public as you like) where you can collect all your "global" parameters


So, this code (with global variables) should be part of Program class? Or what is the right way?

or you can directly access the "Ranorex global parameters" through this code:
IDictionary<string, string> idict = TestSuite.Current.Parameters;


Can you bring an example?
User avatar
slavikf
 
Posts: 97
Joined: Mon Sep 13, 2010 10:07 pm
Location: Toronto, Canada

Re: Global parameters - recordings' variables binding

Postby dman » Fri Sep 16, 2011 9:12 am

this is how I did it:

Code: Select all
IDictionary<string, string> idict = TestSuite.Current.Parameters;
string PBDomain = idict["MyDomain"];


with MyDomain defined as global parameter
dman
 
Posts: 24
Joined: Mon Aug 29, 2011 10:33 am
Location: München

Re: Global parameters - recordings' variables binding

Postby kathleen71 » Fri Nov 04, 2011 1:53 pm

Hi,
thank you, exactly what I'm looking for!
kathleen71
 
Posts: 1
Joined: Fri Nov 04, 2011 1:52 pm


Return to General Questions

Who is online

Users browsing this forum: No registered users and 0 guests