Error trying to verify array value from another script unit [//USEUNIT] in current script unit.
I am using TestComplete v11,31,242 and Jscript. I have been using TC and Jscript about three months now. So my understanding is limited. I am creating modular script units for functions that are going to be called repeatedly. Currently scripting search (regression) for patient search (our product is EMR for Hospitals/Clinics).
To perform various searches based on patient name, source, account #, MRN, DOB, admission date, department, group etc. So I am collecting all the patient information by searching for the patient, selecting the patient and going to "View Detail Information". Collecting the above information and placing them in an array "pStat".
The array function unit is called from the "Search" script unit. Then proceeding to perform searches. Once the patient is found, some of the information collected earlier is used to verify accuracy (property checkpoint). At the checkpoint I am getting an error. If I copy/paste the entire array script into the search script, it runs without any error! Can not figure out how to fix this. Please help.
The "array" script:
function getPatientStat()
{
. . .
//select patient Aliases.browser.pifHome.aspnetForm.firstPatient.Click(); //view information Aliases.browser.swce.aspnetForm.menuViewInfo.Click(); //get patient info var pStat = []; var pStat = [Aliases.browser.swce.aspnetForm.panelPatientInfo.Name.contentText, Aliases.browser.swce.aspnetForm.panelPatientInfo.ptSource.contentText, Aliases.browser.swce.aspnetForm.panelPatientInfo.acNum.contentText, Aliases.browser.swce.aspnetForm.panelPatientInfo.MRN.contentText, Aliases.browser.swce.aspnetForm.panelPatientInfo.DOB.contentText, Aliases.browser.swce.aspnetForm.panelPatientInfo.aDate.contentText, Aliases.browser.swce.aspnetForm.panelPatientInfo.Dept.contentText, Aliases.browser.swce.aspnetForm.panelPatientInfo.Group.contentText];
The script collecting all the intended information. But failing in property checkpoint in "search" Unit.
Property checkpoint:
//USEUNIT Patient_Info
//gather patient info
Patient_Info.getPatientStat();
//select patient Aliases.browser.pifHome.aspnetForm.firstPatient.Click(); //view information Aliases.browser.swce.aspnetForm.menuViewInfo.Click(); //check MRN
aqObject.CheckProperty(Aliases.browser.swce.aspnetForm.panelPatientInfo.MRN, "contentText", cmpEqual, pStat[3]);
If the array function is included in search script, it runs with no problem.
Thanks in advance!
Dave
you have declared var pStat [] globally (out side function) which is OK
but you are again declaring var pStat [] inside function so the program got confused...
inside of function you do not need Var keyword
just do like
pStat = [Aliases.browser.swce.aspnetForm.panelPatientInfo.Name.contentText, Aliases.browser.swce.aspnetForm.panelPatientInfo.ptSource.contentText, Aliases.browser.swce.aspnetForm.panelPatientInfo.acNum.contentText, Aliases.browser.swce.aspnetForm.panelPatientInfo.MRN.contentText, Aliases.browser.swce.aspnetForm.panelPatientInfo.DOB.contentText, Aliases.browser.swce.aspnetForm.panelPatientInfo.aDate.contentText, Aliases.browser.swce.aspnetForm.panelPatientInfo.Dept.contentText, Aliases.browser.swce.aspnetForm.panelPatientInfo.Group.contentText];
or better
pStat[0] = Aliases.browser.....Name.contentText pStat[1] =Aliases....pt.Source.contentText
pl type full-name instead of dots above
Also a good place to grasp programming concepts is http://www.w3schools.com remember this is not jScrip TC have but most concepts are similer