[TechCorner Challenge #9] Generate a random number within a range
- 5 years ago
Task: Generate a random number within the following range (30-75) in TestComplete using a scripting language of your choice.
This is a solution created for [TechCorner Challenge #9]
I used math random() method in javascript to do that, let me try to do it in another language as well.
//JavaScript //JScript function test() { Log.Message(getRandomNumber(30,75)) } function getRandomNumber(min, max) { return Math.floor(Math.random() * (max - min + 1) ) + min; }
- 5 years ago
Task: Generate a random number within the following range (30-75) in TestComplete using a scripting language of your choice.
This is a solution created for [TechCorner Challenge #9]
The following Vb Script code demonstrates how to generate random integers that fall within a specified range from 30 to 75. Here, I have used 'Rnd' function
'VBScript Function RandomNumber_In_givenRange() Dim Minimum Dim Maximum Minimum = 30 Maximum = 75 Randomize Log.Message Int((Maximum - Minimum + 1) * Rnd + Minimum) End Function
- 5 years ago
Task: Generate a random number within the following range (30-75) in TestComplete using a scripting language of your choice.
This is a solution created for [TechCorner Challenge #9]
Hi folks, I gather you just want to have the value returned, not actually automate input of that value into an application?
If so, here's some Python.
#python from random import randrange Log.Message(randrange(30, 75, 1))