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.
Can't use getElementsByTagName.length value as loop parameter
I have following code in sahi script:
var $inputLength = document.getElementsByTagName("button").length;
_alert($inputLength);
for(var $i=0; $i<$inputLength; $i++)
{
_alert("test");
}
Result is:
_alert($inputLength); -> gives me 21 in popup
but
for loop doesn't start code inside brackets. I don't know why "$inputLength" value isn't assigned as 21 number ? Is "21" a string ?
var $inputLength = document.getElementsByTagName("button").length;
_alert($inputLength);
for(var $i=0; $i<$inputLength; $i++)
{
_alert("test");
}
Result is:
_alert($inputLength); -> gives me 21 in popup
but
for loop doesn't start code inside brackets. I don't know why "$inputLength" value isn't assigned as 21 number ? Is "21" a string ?
Answers
if ()
{
}
you have to write it as
if () {
}
if this does not fix it, try to use
var $inputLength = 0
_set(inputLength ,document.getElementsByTagName("button").length);
for(var $i=0; $i<$inputLength; $i++) {
_alert("test");
}