0

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-------------------

  • Do you have files in the second computer at C:/Work/Example.xls and C:/Work/CheckExample.xls? – Vivek V Dwivedi Oct 10 '16 at 09:01
  • Yes I have transferred both of them in my second computer – Dumbo The Elephant Oct 10 '16 at 12:23
  • Is there any error that you are getting? Your code shows that its a success. Try with small things, check if the file is being read correctly or not. If yes, then come to the loop. It's a standard JS loop, so it will work irrespective of computer. Only thing I can see here is that the path for files are different on both the computers and hence the files are not being included. – Vivek V Dwivedi Oct 10 '16 at 18:44

1 Answers1

0

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++){
bummi
  • 27,123
  • 14
  • 62
  • 101