In CasperJS, global variable cannot be accessed inside function.
The following code will return null
var globalVar;
function myFunction(){
globalVar = 1;
return globalVar;
}
echo(myFunction());
Output: null
The following code works
var globalVar;
function myFunction(){
var localVar = 1;
return localVar;
}
globalVar = myFunction();
echo(globalVar);
Output: 1