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.
parseInt() returns NaN need a hand
Hello everyone I need a hand in parseInt department. I'm trying to run a loop until it hits the maxlength of a textbox to generator after a random based on the maxlength. For example if the maxlength of the textbox is 2 it generates a random number between 1 and 99. If it's 4 it generates a random between 1 and 9999 and so on.
The problem is that due to the code it never enters the loop because it's a string and not an Integer.
The code is the following:
$fullname= "testcase"
function maxed()
{
var $evaluator = document.querySelector($fullname).getAttribute('maxlength');
// The Maxlength is 4
return $evaluator;
}
var $maxlength = maxed();
var $counter= 0;
for (;counter<maxlength; counter++)
{
$multiplier *= 10;
$multiplier += 9;
}
Am I missing any type of code before to include java expressions in Sahi or is this a bug? I've tried a lot of options already. Thank you.
The problem is that due to the code it never enters the loop because it's a string and not an Integer.
The code is the following:
$fullname= "testcase"
function maxed()
{
var $evaluator = document.querySelector($fullname).getAttribute('maxlength');
// The Maxlength is 4
return $evaluator;
}
var $maxlength = maxed();
var $counter= 0;
for (;counter<maxlength; counter++)
{
$multiplier *= 10;
$multiplier += 9;
}
Am I missing any type of code before to include java expressions in Sahi or is this a bug? I've tried a lot of options already. Thank you.
Comments
var $evaluator=_getAttribute (_textbox($elementname), "maxlength");
I did try with the _set command but without any good result. The only choice was the getAttribute which fortunately worked. I'm using Sahi Pro 7.5.0 and running it in IE11 environment.