javascriptsahi

Sahi unable to run the for loop


I have been using a test tool call Sahi.

So basically I transferred one of my file, Example.sah , from one computer to another computer. When I run it on my another computer, it can't read the for loop for the code below. I have changed it to while loop and it doesn't work either. However, the codes below worked on my previous computer.

-----------------------------------CODES----------------------------------------

var $userinfo = _readExcelFile("C:/Work/Example.xls");
var $userinfo1 = _readExcelFile("C:/Work/CheckExample.xls");


var $i=0
for ($i++; $i<$userinfo;){

    var $Id = $userinfo[$i][0];
    var $Int = $userinfo[$i][1];
    var $Int2 = $userinfo[$i][2];
    var $BigInt1 = $userinfo[$i][3];
    var $BigInt2 = $userinfo[$i][4];
    var $Double1 = $userinfo[$i][5];
    var $Double2 = $userinfo[$i][6];

    _click(_link("Edit"));
    _click(_link("New"));
    _setValue(_textbox("Title"), $Id);
    _setValue(_numberbox("TestInt001"), $Int);                                                                                                                                                                                                             
    _setValue(_numberbox("TestInt002"), $Int2);
    _setValue(_numberbox("TestBigint001"), $BigInt1);
    _setValue(_numberbox("TestBigint002"), $BigInt2);
    _setValue(_numberbox("TestDouble001"), $Double1);
    _setValue(_numberbox("TestDouble002"), $Double2);
    _click(_cell(0));
    _doubleClick(_cell(0));
    _click(_submit("Ok"));

    var $Idx = $userinfo1[$i][0];
    var $Intx = $userinfo1[$i][1];
    var $Int2x = $userinfo1[$i][2];
    var $BigInt1x = $userinfo1[$i][3];
    var $BigInt2x = $userinfo1[$i][4];
    var $Double1x = $userinfo1[$i][5];
    var $Double2x = $userinfo1[$i][6];


    _assertContainsText($Idx, _link($Id));
    _assertContainsText($Intx, _cell($Int));
    _assertContainsText($Int2x, _cell($Int2));
    _assertContainsText($BigInt1x, _cell($BigInt1));   
    _assertContainsText($BigInt2x, _cell($BigInt2));
    _assertEqual($Double1x, _getText(_cell($Double1)));
    _assertEqual($Double2x, _getText(_cell($Double2)));



}

--------------------------OUTPUT----------------------------------------------

------------------- Stopped Playback: SUCCESS-------------------


Solution

  • I feel your error is in the below section :

    var $i=0
    for ($i++; $i<$userinfo;){
    

    You can try replacing it with this

    for ($var $i=0;$i<$userinfo;$i++){