如何生成随机数

发布于 2024-09-01 15:44:58 字数 99 浏览 2 评论 0原文

我必须使用 Selenium IDE 创建家庭作业测试并创建一个场景来生成随机数。我正在努力解决我需要输入的内容以及要输入的字段。

我应该输入什么?: 命令 目标 价值

I have to create a test for homework using Selenium IDE and create a scenario to generate a random number. I'm struggling with what I need to type and what field to type in.

What should I type in?:
Command
Target
Value

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

忘你却要生生世世 2024-09-08 15:44:58

替代文本

替代文本
(来源:wisc.edu

   

alt text

alt text
(source: wisc.edu)

  

从﹋此江山别 2024-09-08 15:44:58

我总是用它来创建随机用户名和电子邮件

storeEval > Math.round (Math.random() * 1357) > random
type > id=UserName > selenium${random}

storeEval > Math.round (Math.random() * 1357) > random
type > id=UserEmail > selenium${random}@am.com

我希望它们可以帮助你

i always use this to create random username and e-mails

storeEval > Math.round (Math.random() * 1357) > random
type > id=UserName > selenium${random}

and

storeEval > Math.round (Math.random() * 1357) > random
type > id=UserEmail > selenium${random}@am.com

i hope they can help you

源来凯始玺欢你 2024-09-08 15:44:58

我经常在 JUnit 测试中使用它来创建随机输入值。

int randNum = (int) (Math.random() * MAXVALUE);

I use this often in my JUnit tests to create random inputs values.

int randNum = (int) (Math.random() * MAXVALUE);
忆梦 2024-09-08 15:44:58

这就是我使用的:

Random rand = new Random(System.currentTimeMillis());
int num = rand.nextInt(range);

范围是您想要返回的最大数字。 Num 将介于 0 和 range 之间。

This is what I use:

Random rand = new Random(System.currentTimeMillis());
int num = rand.nextInt(range);

Range is the max number you want to return. Num will be something between 0 and range.

秋千易 2024-09-08 15:44:58

您可以使用

Random rndNum = new Random();    System.out.println("Num "+rndNum.nextInt());

单个数字,例如:Num -1597641332

或尝试

Random rndNum= new Random();    int rndNum1 = 0;

   for (int nbr = 1; nbr <= 3; nbr++) {
       rndNum1 = rndNum.nextInt();
       System.out.println("Number: " + rndNum1);    }

使用多个随机数,例如

Number:-1891834125
编号:-1541629941
号码:-129634738

you can use

Random rndNum = new Random();    System.out.println("Num "+rndNum.nextInt());

for a single number like: Num -1597641332

or try

Random rndNum= new Random();    int rndNum1 = 0;

   for (int nbr = 1; nbr <= 3; nbr++) {
       rndNum1 = rndNum.nextInt();
       System.out.println("Number: " + rndNum1);    }

for multiple number of random numbers like

Number: -1891834125
Number: -1541629941
Number: -129634738

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文