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.

Sahi doesn't work when Sun JDBC ODBC for MS-Excel is used

sumeetsumeet Members
edited November -1 in Sahi - Open Source
I have a script which creates some entries and the created entry gets displayed to a table in the application. And when I try to select the new entry from the table it does not find the table object and throws below error

_click(_row(_table("null"), "ND0099001")); TypeError: 'rows' is null or not an object
No trace available

I have statement in my sahi script as below -

_click(_row(_table($funcrs[$i]["Element"]), $funcrs[$i]["Value"]));

Note in above statement the "Element" and "Value" are nothing but the object and the data to find in the table, which I have kept in the Excel file

And this only happens when I use driver - "sun.jdbc.odbc.JdbcOdbcDriver"

But if I use driver - "com.hxtt.sql.excel.ExcelDriver" then it works fine.

Can someone help me to get the solution.

Comments

  • narayannarayan Administrators
    Sumeet,

    It is surprising that the driver found $funcrs[$i]["Value"] (=ND0099001) but not $funcrs[$i]["Element"]. Do you think there could be some other mistake?
  • So do you mean to say that driver is not able to pick the value correctly. As my table id is numeric identifier and it returns the null when i debug. But the other driver works with same set of data in excel, so am not sure whether its sahi problem or driver problem.
  • I think its limitation of driver that it returns the null when there is numeric data available in Excel cell. Workaround is to format the excel with type as "Text".
  • Hi Sumeet,

    I am able to read/write from/To an excel file which is having several row/column data. Here is the sample of script what I used. Hope you can get some help from this.

    var db = _getDB("sun.jdbc.odbc.JdbcOdbcDriver","jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=D:/sahi/scripts/test2.xls","","");
    var $rs = db.select("select * from [Sheet1$]");
    var $data1 =($rs[$i]["data1"]);
    var $data2 =($rs[$i]["data2"]);
    var $data3 =($rs[$i]["data3"]);
    var $data4 =($rs[$i]["data4"]);
    var $data5 =($rs[$i]["data5"]);
    //var $data6 =($rs[$i]["data6"]);
    var $data7 =($rs[$i]["data7"]);
    //var $data8 =($rs[$i]["data8"]);
    //var $data9 =($rs[$i]["data9"]);
    len=100
    for(var $i=0;$i<=1;$i++)
    {
    _popup("12")._setValue(_textbox("eventCode"), $data1);
    _popup("12")._setValue(_textbox("externalEventCode"), $data2);
    _popup("12")._setValue(_textarea("eventDesc"), $data3);
    _popup("12")._setValue(_textbox("billingCode"), $data4);
    _popup("12")._setSelected(_select("category"), "WALLPAPER");
    _popup("12")._setValue(_textbox("billingSubCode"), $data5);
    _popup("12")._click(_radio("billingFlag"));
    _popup("12")._click(_radio("billingEventsFlag"));
    _popup("12")._setValue(_textbox("price"), $data7);
    _popup("12")._setValue(_textbox("noOfUnits"),"9");
    _popup("12")._setSelected(_select("eventTypeCode"), "Download");
    _wait(6000);
    _popup("12")._click(_button("Add"));
    _wait(6000);
    _debugToFile(($rs[$i]["data1"])++($rs[$i]["data2"])++($rs[$i]["data3"])++($rs[$i]["data4"])++($rs[$i]["data5"])++($rs[$i]["data6"])++($rs[$i]["data7"])++($rs[$i]["data8"]), "D:\\utpal.csv");
    _alert("script is successful");
  • sorry i forgot to check on "Never show smilies as icons for this post" option. Please conside lines as given below for the portion where smilies comes.
    var $data1 =($rs[$i]["data1"]);
Sign In or Register to comment.