How to use a variable of a code module to another code modul
-
- Posts: 1
- Joined: Thu Aug 25, 2016 10:16 am
How to use a variable of a code module to another code modul
I have Created a variable in one code module.Can i use that variable in another code module?If SO how to use
Re: How to use a variable of a code module to another code modul
Please read the user guide, it explains clearly how to handle this situation.
http://www.ranorex.com/support/user-guide-20.html
You probably will need to use a Global or Test Case parameter to hold the value of the variable between module executions. Bind the parameter to the variables in each module.
http://www.ranorex.com/support/user-guide-20.html
You probably will need to use a Global or Test Case parameter to hold the value of the variable between module executions. Bind the parameter to the variables in each module.
Shortcuts usually aren't...
Re: How to use a variable of a code module to another code modul
First, Declare the variable and make it static: (Right Click in code module > Insert New Module Variable)
Now you can use this variable in another code module. There are two ways you can use it:
1. With Inheritance:
Note: This will also work without making your variable static but will be its own instance when inherited.
2. Without Inheritance:
Code: Select all
static string _myVar = "testVar";
[TestVariable("0f6808ec-bef9-44de-ae74-2a7de9eb6baf")]
static public string myVar
{
get { return _myVar; }
set { _myVar = value; }
}
1. With Inheritance:
Code: Select all
public class CodeMod2 : CodeMod1, ITestModule
myVar = "myVar-Modified";
2. Without Inheritance:
Code: Select all
CodeMod1.myVar = "myVar-Modified";