如何在不使用 0 的情况下在空手道 DSL 功能文件中生成随机的 10 位数字?

How to generate a random 10 digit in Karate DSL feature file without using the 0?

* def random_number =
"""
function(s) {
  var randomInt2 = Math.random().toFixed(s).split('.')[1];
  var randomNum = randomInt2;
  return randomNum;
}
"""

我可以通过调用此方法生成一个 10 位数字,但我不希望生成的数字中有 0。非常感谢任何帮助。

这应该有效:

* def random = function(){ var temp = ''; karate.repeat(10, function(){ temp += Math.floor(Math.random() * 9) + 1 }); return temp; }