18 January 2026:


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.

how to use a forLoop statment

ibsolutionibsolution Members
edited November -1 in Sahi - Open Source
Narayan,

i would like to insert a data using a loop, because this value that i should entered like
001,002,003...

i would like to use like this. i know my code is wrong but i can not make it work properly. Because SAHI Script does not have a tutorial programming.

function setIdentity(){
var indentityarr=[];
indentityarr[0]="001";
indentityarr[1]="002";
for (var i=0; i<2; i++){
_setValue(_textbox("no"), indentityarr[$i]);
_click(_button("NEXT >>"));
}
}

_click(_link("Locker Baru"));
_wait(3000);
setIdentity();

how to make that code work properly ?

Regards,

Andy Susanto

Comments

  • You have $i as your array index. However in your for loop you only have i, could this be the problem?
  • narayannarayan Administrators
    Yes, as Doug says, the variable i should be $i everywhere. Also indentityarr should be $indentityarr

    Regards,
    Narayan
Sign In or Register to comment.