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.

Using a FOR loop, while fetching a value from a table using sahi, does not give proper result

sgupta2sgupta2 Members
edited September 2013 in Sahi Pro
My Script :
var $table = document.getElementById('ABC')
var $rows = $table.rows ;

for($i=1 ; $i<$rows.length ;$i++)
{
do something ;
}

my $rows.length = 1000 still this condition is coming as unfulfilled and control is not going inside FOR loop. Instead, if I rephrase it like

for($i=1 ; ;$i++)
{
if ($i>=$rows.length)
{ break ; }
else
{
do something ;
}
}

it is working fine. I tried storing the rows.length value in another variable and then using that variable but still it does not work. Could you please help me with this.?

Best Answer

  • Hi sgupta2,
    Use the following code:
    _set($rowsLength,$table.rows.length)
    
    and use the above variable in your for loop.

    Please let me know whether it works for you.

    Regards.

Answers

  • Hi Pratyush,

    It worked. Could you please tell me why does not it work other way round.

    Thanks
  • Hi sgupta2,
    Please have a look at the following link:
    http://sahi.co.in/w/_set
    

    Regards.
Sign In or Register to comment.