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.
array return by java could use _writeCSVFile?
var $c = Packages.MyCsvManager.getList();
_debug($c);
_writeCSVFile($c, "c:/aa.csv") ;
MyCsvManager.java
console
Debug: "A","00000000001"],["A","00000000002"],["A","00000000003"],["A","00000000004"],["A","00000000005"
aa.csv is generated but empty.
var $data = [
[2, 3, 5],
[1, 2, 4],
[4, 3, 7]
]
_writeCSVFile($c, "c:/bb.csv") ;
bb.csv is generated and have contents.
why aa.csv is empy
_debug($c);
_writeCSVFile($c, "c:/aa.csv") ;
MyCsvManager.java
public static String getList(){
List addList = new ArrayList();
addList.add("00000000001");
......
addList.add("00000000005");
List rowList = new ArrayList();
for(int i=0; i<addList.size(); i++){
rowList.add("A");
rowList.add(addList.get(i));
addList.set(i, rowList);
rowList = new ArrayList();
}
return getJSObject(addList);
}
public static String getJSObject(final List<ArrayList<String>> list) {
StringBuffer sb = new StringBuffer();
sb.append("[[");
boolean isFirst1 = true;
for (Iterator<ArrayList<String>> iterator = list.iterator(); iterator.hasNext();) {
if (isFirst1)
isFirst1 = false;
else
sb.append(",[");
ArrayList<String> record = iterator.next();
for (int i = 0; i < record.size(); i++ ) {
if(i!=0){
sb.append(",");
}
String value = record.get(i);
sb.append("\"" + Utils.makeString(value) + "\"");
//sb.append("\"" + Utils.escapeDoubleQuotesAndBackSlashes(value) + "\"");
}
sb.append("]");
}
sb.append("]");
return sb.toString();
}
console
Debug: "A","00000000001"],["A","00000000002"],["A","00000000003"],["A","00000000004"],["A","00000000005"
aa.csv is generated but empty.
var $data = [
[2, 3, 5],
[1, 2, 4],
[4, 3, 7]
]
_writeCSVFile($c, "c:/bb.csv") ;
bb.csv is generated and have contents.
why aa.csv is empy
Comments
What we are doing is taking a JSON string and converting it to a javascript object; then passing it to _writeCSVFile.
Regards,
Narayan
_debug($data);
_writeCSVFile($data, $fileName) ;
Debug: A,00000000001,A,00000000002,A,00000000003,A,00000000004,A,00000000005
the file is still empty
are there something wrong in the getJSObject I written ,
not the net.sf.sahi.plugin.DBClient#getJSObject
public static String getList(){} to
public static String[][] getList(){}
?
var $data;
_set($data, _eval($c));
_writeCSVFile($data, $fileName) ;
i rewrite the code , and it works
You were using _eval instead of eval, which is not correct.
liprise,
Could you please elaborate on your problem?
Regards,
Narayan