18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
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.
table element becomes null, when variable reaches 100 in loop
Hi All,
I am running a FOR loop over a table element, which has 1000+ rows. It runs properly till 99, but as soon as it reaches 100, the table element becomes null and henceforth it doesn't provide expected result.
My code is:
Controller shows the log as:
I am not able to understand, how the element becomes null, when variable $m reaches 100...
Kindly help in this issue.
I am running a FOR loop over a table element, which has 1000+ rows. It runs properly till 99, but as soon as it reaches 100, the table element becomes null and henceforth it doesn't provide expected result.
My code is:
$Start_RowIndex = 2;
$TotalCount = 1026;
for($k=$Start_RowIndex,$m=$Start_RowIndex;$k<$TotalCount;$k++)
{
$j=1;
$ActualValue.length = 0;
$Tabid = "box";
for($i=0;$i < 5;$i++)
{
if(($value[2] == "class") || ($value[2] == "id")){
if(_exists(_cell($j,_in(_table($Tabid).rows[$m])))){
_set($ActualValue[$i],_getText(_cell($j,_in(_table($Tabid).rows[$m]))));
$j += 1;
}
}
else{
if(_exists(_cell($j,_in(_table(0,$Tabid).rows[$m])))){
_set($ActualValue[$i],_getText(_cell($j,_in(_table(0,$Tabid).rows[$m]))));
$j += 1;
}
}
}
$RowTxt=$ActualValue.join(",");
$FinalStr = $k + "=>" + $RowTxt;
WriteConfFile($value2,$FinalStr);
$m ++;
if(_exists(_span("yui-pg-current"))&&($m > 21))
{
$m=$Start_RowIndex;
_click(_image("next.jpg"));
_wait(500);
_wait(500);
}
}
Controller shows the log as:
setServerVar('___lastValue___1330424039921', _exists(_cell(1, _in(_table("box").rows[98]))));
setServerVar('\$ActualValue[\$i]', _getText(_cell(1,_in(_table("box").rows[98]))));
setServerVar('___lastValue___1330424040109', _exists(_cell(2, _in(_table("box").rows[98]))));
setServerVar('\$ActualValue[\$i]', _getText(_cell(2,_in(_table("box").rows[98]))));
setServerVar('___lastValue___1330424040312', _exists(_cell(2, _in(_table("box").rows[98]))));
setServerVar('___lastValue___1330424040421', _exists(_cell(3, _in(_table("box").rows[98]))));
setServerVar('\$ActualValue[\$i]', _getText(_cell(3,_in(_table("box").rows[98]))));
setServerVar('___lastValue___1330424040625', _exists(_cell(4, _in(_table("box").rows[98]))));
setServerVar('\$ActualValue[\$i]', _getText(_cell(4,_in(_table("box").rows[98]))));
setServerVar('___lastValue___1330424040921', _exists(_span("yui-pg-current")));
setServerVar('___lastValue___1330424041015', _exists(_cell(1, _in(_table("box").rows[99]))));
setServerVar('\$ActualValue[\$i]', _getText(_cell(1,_in(_table("box").rows[99]))));
setServerVar('___lastValue___1330424041218', _exists(_cell(2, _in(_table("box").rows[99]))));
setServerVar('\$ActualValue[\$i]', _getText(_cell(2,_in(_table("box").rows[99]))));
setServerVar('___lastValue___1330424041421', _exists(_cell(2, _in(_table("box").rows[99]))));
setServerVar('___lastValue___1330424041531', _exists(_cell(3, _in(_table("box").rows[99]))));
setServerVar('\$ActualValue[\$i]', _getText(_cell(3,_in(_table("box").rows[99]))));
setServerVar('___lastValue___1330424041828', _exists(_cell(4, _in(_table("box").rows[99]))));
setServerVar('\$ActualValue[\$i]', _getText(_cell(4,_in(_table("box").rows[99]))));
setServerVar('___lastValue___1330424042031', _exists(_span("yui-pg-current")));
setServerVar('___lastValue___1330424042125', _exists(_cell(1, _in(null))));
setServerVar('___lastValue___1330424042234', _exists(_cell(1, _in(null))));
setServerVar('___lastValue___1330424042328', _exists(_cell(1, _in(null))));
I am not able to understand, how the element becomes null, when variable $m reaches 100...
Kindly help in this issue.
Comments
I have reacently encountered the same issue and here you can find the steps to fix it:
http://sahi.co.in/forums/discussion/6780/not-able-to-iterate-through-array-with-more-than-100-elements#Item_3
Regards,
Iskren