Trying to select a random value from a data source
I'm running a test whereby I fill out a form that requires first name, last name, email address. I don't want a data loop as I'm only completing the form out once.
I found this post which I thought was going to work.
However when executing the test it fails for the following reason 'Unable to evaluate the operation's "Text" parameter. Error: ReferenceError: Variables is not defined'.
I've set my value in the test as per this post as a code expression
I'm new to TestComplete so not sure if I've done something wrong or its not possible to select a one off random value from a data source?
So I'm 1st setting a variable of 'CurrentNumber' to get a random number with this line of code
Math.floor(Math.random() * 100) + 1
Then I'm using the SetText operation with this command as a mode of Code Expression (which I'm assuming is the correct one to use?) to add the text from either a data table or excel spreadsheet that contains a list of names. I'm using the number variable 'CurrentNumber' to select the random name.
Hope this makes sense
This is actually from an error in how the related post was built out.
TestComplete will truncate the 'Values' to save screen real estate, this means the code snippet in the linked doc is technically incomplete.
Below is what TC will show you of that code expression once you have clicked out of it, notice that it matches the doc;
Though if we click on the 'Value' for the textBox step, we see the entire value =
The correct code expression should be = 'KeywordTests.Test1.Variables.Random(....'
Essentially we are missing the location of the variable in the image that is present in the linked doc.
Sorry for the confusion, I hope this helps to clear things up!
Solutions Engineer @ SmartBear