Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Scripting - random 11 digit number

LegacyForum Posts: 1,664 ✭✭
edited December 2016 in SOAtest
I have a test for one operation which has one input parameter and it takes 11 digit number.
Can you please provide me a testscript which generates any random 11 digit number for input field.


  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    edited January 2006
    Hi LeapTester,

    Here is the script for generating random 11 digit sequences.
    from java.util import *

    def myRandom():
       rand = Random();
       # Make sure first digit is not zero
       ret = str(rand.nextInt(9) + 1);
       index = 0;
       while index < 10:
           ret = ret + str(rand.nextInt(10));  
           index = index + 1;
       return ret

    I assumed that the first digit cannot be zero. If that is the wrong assumption, please change the while loop to run 11 times instead of 10 and change

    CODEret = str(rand.nextInt(9) + 1);


    ret = '' # 2 single quotes