Generate Random Number

I would like to generate a random number in Test Studio. This number will be used in an input control or for a similar purpose.


This is possible with a coded solution. The .NET Framework provides the System.Random class which can be used to generate random numbers.

In this example, we'll navigate to this Telerik demo page and use the DataPager control to navigate to a random page number between 1 and 10.


System.Random random = new  System.Random();
int randomPage = random.Next(1, 11);

Find.ByExpression<HtmlInputText>("id=~TextBox_text").Text = randomPage.ToString();

Dim random As New System.Random()
Dim randomPage As Integer = random.[Next](1, 11)

Find.ByExpression(Of HtmlInputText)("id=~TextBox_text").Text = randomPage.ToString()
Find.ByExpression(Of HtmlInputControl)("id=~GoToPageButton").Click()
Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article