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.

Can not get the random number, please help!

ziscloudziscloud Members
edited November -1 in Sahi - Open Source
Hi all,
I want to get a random number based on the size of the row of
one table, I write following script but it does not work, anybody can
help!

var $recordNo = _table(7).rows.length;
var $tickNo = _random(Number($recordNo));
_alert($recordNo); //13
_alert(typeof($recordNo)); //number
_alert($tickNo.valueOf()); //NaN
_alert(typeof($tickNo.valueOf())); //number

Thanks a lot!

Comments

  • narayannarayan Administrators
    Use _set to get the value of row length from browser. Then just pass it to _random.
    I hope you understand that the parameter passed to _random, specifies the maximum value that _random will return.
    _set($recordNo, _table(7).rows.length);
    var $tickNo = _random($recordNo); 
    

    Regards,
    Narayan
  • Thanks narayan, your script help me a lot!

    I understand the meaning of the parameter passed to the _random function, thanks your kindly remind!
Sign In or Register to comment.