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.

Script fails if table has more than 2 records using access database

edited November -1 in Sahi - Open Source
Hi,

I have created one script for verifying the data present in access database using sahi.
If the table has 1 0r 2 records, the script pass otherwise fail.
The index treats randomly.
I am attaching script and table 'access'.
please verify at your end and let know.

Please change the path of the table in script.
Create following table in Access database:

ID NAME AGE
1 Arun 30
2 Ashok 29
3 Kamlesh 28
4 Raja 35



Please find the script below:

var db = _getDB("sun.jdbc.odbc.JdbcOdbcDriver","jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Data\\Assignment2.mdb;readOnly=false","","");

// Run a select

var $rs = db.select("select * from Access");


_assertEqual("1", $rs[0]["ID"]);
_assertEqual("Arun", $rs[0]["NAME"]);
_assertEqual("30", $rs[0]["AGE"]);


_assertEqual("2", $rs[1]["ID"]);
_assertEqual("Ashok", $rs[1]["NAME"]);
_assertEqual("29", $rs[1]["AGE"]);


_assertEqual("3", $rs[2]["ID"]);
_assertEqual("Kamlesh", $rs[2]["NAME"]);
_assertEqual("28", $rs[2]["AGE"]);

_assertEqual("4", $rs[3]["ID"]);
_assertEqual("Raja", $rs[3]["NAME"]);
_assertEqual("35", $rs[3]["AGE"]);

Please let know.

Regards
Ashok

Comments

  • narayannarayan Administrators
    Hi Ashok,

    If you feel the order is not proper, try using "select * from Access order by ID asc".
    The ordering must be a quirk of the driver used.
    (Sahi just dumbly passes on the commands to the underlying driver and returns the results. Ordering is not something that Sahi manipulates, so my guess is, it must be the driver.)

    Regards,
    Narayan
  • Hi Narayan,

    Thanks.

    Now the issue has resolved as you said in comment #2.

    Regards
    Ashok
Sign In or Register to comment.