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.
Data driven testing, reading data from MS Excel sheet.
I'm facing some problem in reading data from excel sheet,
I have done the following configuration changes to sahi.bat
SET EXT_CLASS_PATH=D:\softwares\sahi\sahi\lib\Excel_JDBC30.jar;
#SET EXT_CLASS_PATH=%EXT_CLASS_PATH%;..\extlib\mysql-connector-java-5.0.4-bin.jar
SET SAHI_CLASS_PATH=..\lib\Excel_JDBC30.jar;..\lib\sahi.jar net.sf.sahi.Proxy
SET MOZ_NO_REMOTE=1
java -classpath %EXT_CLASS_PATH%;%SAHI_CLASS_PATH% net.sf.sahi.Proxy
I have added Excel_JDBC30.jar in sahi\lib.
Created a folder name Test data inside sahi folder and added data.xls......(sahi\Testdata\Data.xls)
Code looks like this....
var $driver="com.hxtt.sql.excel.ExcelDriver";
var $datafile="jdbc:excel:/D:/softwares/sahi/sahi/Testdata/data.xls";
var $db=_getDB($driver,$datafile,"","");
var $rs = [];
$rs = $db.select("select * from userdata");
_setValue(_textbox("username"), $rs[1]);
I'm jst checking to retrive username which i'm getting a message as Undefined.
Can anyone help me to debug this what might be wrong.
I have done the following configuration changes to sahi.bat
SET EXT_CLASS_PATH=D:\softwares\sahi\sahi\lib\Excel_JDBC30.jar;
#SET EXT_CLASS_PATH=%EXT_CLASS_PATH%;..\extlib\mysql-connector-java-5.0.4-bin.jar
SET SAHI_CLASS_PATH=..\lib\Excel_JDBC30.jar;..\lib\sahi.jar net.sf.sahi.Proxy
SET MOZ_NO_REMOTE=1
java -classpath %EXT_CLASS_PATH%;%SAHI_CLASS_PATH% net.sf.sahi.Proxy
I have added Excel_JDBC30.jar in sahi\lib.
Created a folder name Test data inside sahi folder and added data.xls......(sahi\Testdata\Data.xls)
Code looks like this....
var $driver="com.hxtt.sql.excel.ExcelDriver";
var $datafile="jdbc:excel:/D:/softwares/sahi/sahi/Testdata/data.xls";
var $db=_getDB($driver,$datafile,"","");
var $rs = [];
$rs = $db.select("select * from userdata");
_setValue(_textbox("username"), $rs[1]);
I'm jst checking to retrive username which i'm getting a message as Undefined.
Can anyone help me to debug this what might be wrong.
Comments
This exception is thrown in the console, I'm using Excel 2007:
java.sql.SQLException: [Microsoft][ODBC Excel Driver] The Microsoft Jet database
engine could not find the object 'Hoja1'. Make sure the object exists and that
you spell its name and the path name correctly.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(Unknown Source)
at net.sf.sahi.plugin.DBClient.getResult(DBClient.java:105)
at net.sf.sahi.plugin.DBClient.select(DBClient.java:83)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:142)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:20
1)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:84)
at org.mozilla.javascript.gen.c54._c12(<cmd>:81)
at org.mozilla.javascript.gen.c54.call(<cmd>)
at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:64)
at org.mozilla.javascript.gen.c55._c0(<cmd>:6)
at org.mozilla.javascript.gen.c55.call(<cmd>)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:3
37)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:275
5)
at org.mozilla.javascript.gen.c55.call(<cmd>)
at org.mozilla.javascript.gen.c55.exec(<cmd>)
at org.mozilla.javascript.Context.evaluateString(Context.java:1144)
at net.sf.sahi.rhino.ScriptRunner.run(ScriptRunner.java:94)
at java.lang.Thread.run(Unknown Source)
Try using:
_set($rs, $db.select("select * from userdata"));
instead of :
$rs = $db.select("select * from userdata");
Another thing, although I havnt used excel datatables but I think it must work more or less the same way. I think you will have to define $rs as a 2D array like
$rs[0]=[];
and when you want to get a value from a particular cell you will have to address it like this:
$rs[row number][COLUMN NAME];
So if the name of the column in your case is say, xyz than: try if this helps
Regards,
Pankaj.