Robot Framework: Generating Unique Random number

后端 未结 5 1180
失恋的感觉
失恋的感觉 2021-01-18 21:46

I have to generate unique random numbers in robot framework. I have used \"Generate Random String\" to get random numbers. Command:

${random}   Generate Ran         


        
5条回答
  •  悲哀的现实
    2021-01-18 22:22

    I think the random module's sample function is the most elegant solution. Here taking 4 out of the set of numbers from 1 to 10 inclusive:

    ${numbers}=    Evaluate    random.sample(range(1, 11), 4)    random
    

    This returns a list of int's. If you want string representation of numbers...

    ${numbers}=    Evaluate    random.sample([unicode(x) for x in range(1, 11)], 4)    random
    

提交回复
热议问题