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.

Unable to fetch data from Table

vikkyjainvikkyjain Members
edited June 2011 in Sahi - Open Source
Hi,

I had written a function to get data from a table.
So I make a demo function to iterate thru table.
"sahi_fileSelectionTable" is id of my table.
Total number of rows = 2 in my table.
When i use "alert(rows.length)" it gives 2
but when i use " alert(rows.length+"");" it gives me "_sahi._table("sahi_fileSelectionTable").rows.length"

Please help me, its not going thru the loop.


function getData()
{
table1 = _table("sahi_fileSelectionTable");
rows = table1.rows;
alert(rows.length);
alert(rows.length+"");
for(var i=0;i< rows.length;i++)
{
alert(i);
}


}


Thanks
Vikky

Comments

  • Hello Vikky,

    If you wish to iterate over a DOM variable, you need to first use _set to take a snapshot of that variable and then use it in the loop.

    Try this:
    _set($rowLength,_table("tableWithId").rows.length);
    for($i=0;$i<$rowLength;$i++){
        _alert($i);
    }
    

    Refer this for more details.

    Regards,
    dkulkarni
  • Hi dkulkarni,

    ITs working fine, thanks for your quick response.
    My problem is solved successfully.


    Thanks
    Vikky Jain
Sign In or Register to comment.