Scripting - random 11 digit number

LegacyForumLegacyForum Posts: 1,669 ✭✭
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.
Thanks
LeapTester
Tagged:

Comments

  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    edited January 2006
    Hi LeapTester,

    Here is the script for generating random 11 digit sequences.
    CODE
    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);

    to

    ret = '' # 2 single quotes
Sign In or Register to comment.