18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
for loop, $i and _setFile
Hi!
When I use $i variable in for loop it increases each time
After _setFile command $i increases. Without it all seems OK.
Also, if $i replace with $ij - it also ok.
When I use $i variable in for loop it increases each time
function uploadFile($elementID, $fileName){
_setFile(_file($elementID), $settings.getUploadDir()+$fileName, "upload/file_from_swf?action=upload");
}
for (var $i=1; $i<=13; $i++) {
_alert($i);
$fname = "op_hd\\"+$i+".png";
$oname = "picture_file_"+$i;
_alert($i);
uploadFile( $oname, $fname );
_alert($i);
_alert("ende");
}
After _setFile command $i increases. Without it all seems OK.
Also, if $i replace with $ij - it also ok.
Comments
Could you please be more specific about the issue.
Regards
sumitra
1
2
3
4
5
6
etc.
with _setFile inside loop it act like this:
1
3
5
7
9
etc.
Put some file input in the form and try to do _setFile() inside for $i loop.
I had verified running below Sahi script on below mentioned html page :
Note: There are chances that $i might be used as global variable and some where else $i is getting incremented.
<html>
<form name="f1" action="test1.html">
<input type="file" id="fileupload0" name="fileupload1">
</form>
</html>
Here is the output that i am getting,
1
2
3
4
5
6
etc.
Regards
Sumitra
But does not that mean that I use local variable $i inside loop?
By the way, why I cant use variables without $ ?
When you write
_alert(i);
Sahi will search for the variable i on the browser (and will not get it)
When you write
_alert($i);
Sahi will evaluate $i on the proxy and pass it to _alert on the browser.
Also, Can you post the full Sahi script?
Regards
Sumitra
You can email to sumitra@sahi.co.in
Regards
sumitra