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.

Assert a Specific value in a csv file

djwhileydjwhiley Members
edited November -1 in Sahi - Open Source
Hi,

I have a csv file that I can download with sahi that could look like like the following:

Date:, 01/02/2011,""
Code, Balance,""
001,1200.00,""
002,1300.00,""

How could I assert specifically the 2nd line first and second field. Then the 3rd & 4th line second field?

I have so far:

var $data = _readCSVFile("C:/tests/file.csv");
for (var $i=2; $i<$data.length-1; $i++){
var $row = $data[$i];

_assertEqual("Code", $row[0]);
_assertEqual("Balance", $row[1]);
_assertEqual("1200.00", $row[1]);
_assertEqual("1300.00", $row[1]);

}


Thanks in advance

Comments

  • maybe you could use 2D-Arrays...
    your $row[0] in _assertEqual("Code", $row[0]) can be written as $data[1][0] (which is 2. row, 1. colum )
    therefor your assert can look like this
    _assertEqual("Code", data[1][0])

    as you are checking every field by its own assert statement, the loop isn't the way to go^^
    _assertEqual("Code", data[1][0]);
    _assertEqual("Balance", data[1][1]);
    _assertEqual("1200.00",data[2][1]);
    _assertEqual("1300.00", data[2][1]);

    regards
    Wormi
  • Thanks that works.

    djwhiley
This discussion has been closed.