function Test(sApp,iIndex)
{
//Array, where form IDs are stored
var arrFormID=new Array();
//Temporarily array for buttons which exist on the form
var arrTmpBtn=new Array();
//Array with IDs of all buttons, which were pushed
//during script execution
var arrButton=new Array();
//This array collects all button IDs from the forms,
//where the script has already been before. It means that
//the IDs of all tested forms are stored in this array
var arrExtButton=new Array();
Log.PutString("Test for "+ Environment.DeviceType() +
" OS " + Environment.OSVersion(),0);
appLaunch(sApp);
for(var i=0 ; i<iIndex ; i++)
{
//Shows the message about test number which disappears
//in 2 seconds, if the tester does not click on it
Alert2("Function Test", "Test ¹ "+i, 2, 0);
//Flag is used to skip the testing of some forms where
//the script has been before
var bFlag;
//Variable stores the quantity of buttons on form
var iBt=0;
//Checks, whether this form was tested before or not
bFlag=CompareFormID(arrFormID);
//If the form was not tested before, then the script
//checks the fields
if(bFlag)
{
//Array for storing error messages
var arrArray=new Array();
TestFields(arrArray, 0);
//Logs the messages from arrArray array
ArrayToLog(arrArray, "Test Fields", 1);
//Zeroizes the array
arrArray.length=0;
//Checks all checkboxes on form
TestCheckBox(arrArray, 0);
ArrayToLog(arrArray, "Test CheckBox",1);
//Zeroizes the array
arrArray.length=0;
//Checks how many buttons are on the form
iBt=GetBtn(arrTmpBtn);
//Records IDs of all buttons from this form to extButton
//array
TmpToExtArray(arrTmpBtn, arrExtButton, iBt);
}
else
{
if(ExtToTmpArray(arrExtButton,arrTmpBtn))
iBt=arrTmpBtn.length;
else
{
//Checks the quantity of buttons on form
var iBt=GetBtn(arrTmpBtn);
//Records all button IDs from the form to extButton
//array
TmpToExtArray(arrTmpBtn, arrExtButton, iBt);
}
}
if(iBt!=0)
{
//Inputs large quantity of buttons to all fields (not more than 50)
//and does not perform button pushing. Then pushes a random button
var arrArray=new Array();
GetFields(arrArray);
BigWord(arrArray, 0, 50);
while(true)
{
//Generates a random index for array of buttons
//existing on active form
var iRand= Rand (iBt-1);
var iTemp=Control.GetFormID();
//If the button push is performed successfully
//then script exits from the cycle
if(Control.Select("##"+arrTmpBtn[iRand],""))
{
arrButton[arrButton.length]="##"+arrTmpBtn[iRand];
//Exits the cycle only if going to another form
if(Control.GetFormID()!=iTemp)
break;
}
}
//Zeroizes temporarily array
arrTmpBtn.length=0;
}
else
{
PutInLog(arrFormID);
ArrayToLog(arrButton,"All buttuns");
Log.PutString("No buttons on form",0);
return;
}
}
PutInLog(arrFormID);
ArrayToLog(arrButton,"All buttuns",10);
}
//------------------------------------------------------------
|