Global variable trouble!
Hello everyone
I am having serious trouble with Global vaiebles! In the past, I did use Global variable successfully. Only difference this time is, I have 3 Global variable coming from UnitA to UnitB and 3 Variables coming from UnitB to UnitC (one new from UnitB). I have wasted much time last week, can not figure out the problem!
I am using TestComplete 12 with JScript. Here is my setup:
UnitA(with UnitB reference) UnitB(with UnitC reference) UnitC
and . . .
UnitA:
var fName
var securityC
var getURL
function atHomePatient(){
Browsers.Item("iexplore", "", Browsers.pX86).Run("https://<url>");
. . .
//select department
Aliases.browser.pageHIS.aspNet.sDept.ClickItem(patient.sDept);
//set admission date
Aliases.browser.pageHIS.aspNet.aDate.SetText(patient.aDate);
//set patient name
Aliases.browser.pageHIS.aspNet.pName.SetText(patient.pName); //i.e: John Smith
fName = patient.pName.split(" ")[0];
Log.Message("Split first name is: " + fName);
//set DOB
Aliases.browser.pageHIS.aspNet.pDOB.SetText(patient.pDOB);
. . .
}UnitB:
function patientSignOn(){
Log.Message("Patient's Name is: " + fName);
Log.Message("Security code is: " + securityC);
Log.Message("Signup url is: " + getURL);
. . .
}Here is the structure of my project:
All three reported 'undefined' in UnitB!
I would really appreciate any help!
Thanks.
Dave
That's to be expect... you are trying to use B unit code in unit A... which is not allowed because you're not allowed circular references...
What this comes down to, honestly, is that you're going to need to re-engineer some stuff so that you keep your code modularized in specific units so you don't end up with circular references. Unfortunately, that's you're only recourse here... in order to call the code you want to call, you need USEUNIT clauses... but you can't do that because doing so puts you in the situation of having circular references... the only solution is to re-engineer.