Forum Discussion
Lucian
7 years agoCommunity Hero
Hey,
From what I understand you are doing it like:
1. Generate a random number and use it in a request;
2. Obtain the previous raw request and extract that number;
3. Use the number again in another request.
I would do it differently:
1. Generate the number and store it in a property;
2. Use it wherever and whenever you want.
Example (I use HTTP requests but you can use anything else - there won't be any difference):
The groovy script can look something like this:
// Generate a random number def randomNumber = org.apache.commons.lang.RandomStringUtils.randomNumeric(12) // Save the value in a test case property for later use testRunner.testCase.setPropertyValue( "randomNumber", randomNumber )
And then whenever you need to refer to the generated number you can just do it as in:
...so ${#TestCase#nameOfYourProperty}
I think this is a cleaner way to go. Cheers! :)
Related Content
- 10 months ago
- 5 years ago
- 6 years ago
- 2 years ago
- 9 years ago
Recent Discussions
- 15 years ago