About Article:
This article will describe how to can achieve the following:
- Generate a random number using NLP in Virtuoso
- Generate a random 2 digit number using NLP in Virtuoso
- Generate a random 3 digit number using NLP in Virtuoso
Problem Statement:
There are use cases where customers would like to generate random strings and random numbers to use them as a test data input for the Application Under Tests
Solution:
Users can utilize the following NLP syntax to generate random numbers: Execute "return Math.floor( Math.random()*ceil) + floor" returning $randomNumber
By updating the ceil and floor values in the above NLP syntax, any random number can be generated within the defined floor and ceil range.
Examples:
- For instance, to generate a random 3-digit number, the following NLP syntax can be used: Execute "return Math.floor( Math.random()*999) + 100" returning $threeDigit
- To use the generated random number in an input field, use the syntax: Write $threeDigit in field "field_name"
- To generate random 2 digit number, use the syntax: Execute "return Math.floor( Math.random()*99) + 10" returning $twoDigit
- To generate a random number within a defined range, use the syntax: Execute "return Math.floor( Math.random()*999) + 1" returning $randomNumber
- To use the generated random number in an input field along with text, use the syntax: Write ${"Id"+$randomNumber } in field "field_name"
The syntaxes mentioned above can also be used to create extensions for generating random numbers.
Comments
0 comments
Please sign in to leave a comment.