| || |
- 1 Post By fegero
Random text and numbers - SilkTest 15.5
I've created a visual script which a user enters their email address in a field. How would I randomize a string creation? For example how could the random generator create the string "asdfewdf"? I can then merge that variable to the static text "@here.com" or something like that.
There is no direct mechanism available in a Visual test that will do what you want but here are a couple of workarounds.
- Create an ActiveData file that contains a column containing random strings, then write a loop that assigns a variable using a loop using the ability to read a random row from an ActiveData file.
- Create a VB.Net script that calculates a random string of the required length and return this via an output parameter, call the VB.Net script and assign it to a Visual test variable and continue from there.
My preference would be the second option.
Issue solved. I created a random number generator in .Net and then did a call from my Virtual Script to the .Net Script. The .Net script then returned the variable with the value back to my Visual Test and placed it in a parameter which I later used in the email address field.
Tags for this Thread