Forum Discussion

DeepaJ's avatar
DeepaJ
Contributor
9 years ago
Solved

Generate Data - not generating random strings but saves a default value

I have a Reference field, where I am entering a random string (min 1 to max 20 chars) and I need this to be unique with a combination of 2 other fields.

I've created this variable using Data Generator > String type, using a combinaion of numbers, letters and space. On the 1st test run, it generates a random string. But after this, it saves this value as the default. So on all my subsequent test runs, instead of generating a new random string, it is using this default value and so it is not a unique reference. I used the 'One value' variable type.

Can anyone suggest what I might be doing incorrectly?

Thanks!

  • NisHera's avatar
    NisHera
    9 years ago

    You can write simple script and call it from keyword test

    following is using jscript to give you random number between 1 and 100

     

    Math.floor((Math.random() * 100) + 1)

4 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    The Data Generator functionality expects that if you need multiple random strings, you will generate them before your test is run and save them in a table of some sort.  That table is what you will access from your test to get the strings.

     

    https://support.smartbear.com/viewarticle/57866/

    • DeepaJ's avatar
      DeepaJ
      Contributor

      Thanks!

      What I am trying to achieve is to input a value into a field, but on every run I want this value to be different. Is there a way to do this automatically without manually changing the input value before the test run?

      • Marsha_R's avatar
        Marsha_R
        Champion Level 3

        First , use the Table choice rather than the One Value choice.  

         

        Then, you can do something like create 60 columns and fill them from the Data Generator with your strings and then use

         

        aqDateTime.GetSeconds(Now) + 1

         

        as an index to that table.  It will probably be random enough for what you need.  You can always refresh the table every once in a while, but this will work for multiple test runs.