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.

No of rows in a table

GeorgeGeorge Members
edited November -1 in Sahi - Open Source
Build: 2011-07-19
Browser : Mozilla firefox 7.0.1
OS : windows XP/7

Can anyone tell me .. how do i findout .. howmany rows exists in a html/table?

George

Comments

  • Hi George,

    You can use it like this:

    var $rowCount = 0;
    _set($rowCount, _table("myTable").rows.length);
    _alert($rowCount);

    Regards
    Sumitra
  • THANK YOU VERYMUCH SUMITRA.
    i got that.. but again i am facing one more problem ... resuming the script...
    i got the table rows to 5 and i want to execute the following statements for 4 times. so i used the following script.. but for some reason... the value taken as $leng = (_table("grid")).rows.length; (i know it is 5.. but the following statement doesnt fall under the loop.
    Can you tell me why? i tried all the possible chances and it shows the no of rows as 5 but...

    $leng = (_table("grid")).rows.length;
    $len = $leng;
    _alert($leng+" "+$len);
    // it shows as 5 space 5
    $sflag=1;
    $var1 = _getText(_cell(_table("grid"), 1, 3));

    $len=$leng;
    if (_condition($len == 5))
    {
    _alert("condition true");
    // it shows true
    }

    $j=1;

    if (_condition($j <= $len))
    {
    _alert("condition true jjjjjj");
    // it shows true
    }
    _alert($j+" "+$len);


    for (var $i=1; $i <= $len; $i++)
    {
    $var2 = _getText(_cell(_table("grid"), $i, 3));

    if (_condition($var1 != $var2))
    {
    sflag=2;
    }

    _alert($len);
    }


    the above loop... is not executing... because it doesn't find the value $i not less than $len
    but actually $i = 1 and $len = 5

    and if i check

    $len=$leng-1;
    _alert($len);
    // here it shows the value as NaN ... so it is not taken as a correct value it seems

    can you tell me a solution to execute the above loop PLEASE

    George



    //_alert("flag " + $sflag);
Sign In or Register to comment.