Please note that Sahi's development and support teams do not actively monitor this. This is more a community forum. If you are a Sahi Pro user looking for commercial support, please email support @ with your query.

parseInt() returns NaN need a hand

RofzillaRofzilla Members
edited May 2018 in Sahi Pro
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.


  • i was able to resolve this issue with the following command:

    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.
Sign In or Register to comment.