Reshma
Reshma

Reputation: 81

Generate multiples in Robot script using RandInt

I would like to generate fake numbers where one is multiple of the other. Currently I have a python file being passed into my Robot script.

*** Settings ***
Library                ../scripts/param.py
*** Test Cases ***
ABC
    ${ans}             parameter  2  8  30
    ${c}=              Set Variable   ${ans[1]}
    ${T}=              Set Variable   ${ans[0]}

and my param.py is:

import random


def parameter(min_no: int, max_no: int, multiplier: int):
    integer = random.randint(min_no, max_no)
    return integer, integer * multiplier

But I would like to include this logic within my Robot script. Please let me know the best way of doing this.

Upvotes: 0

Views: 93

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 386220

You can call python code using inline python evaluation

*** Test Cases ***
AC
    ${c}=  set variable  ${{random.randint(2, 8)}}
    ${t}=  set variable  ${{$c * 30}}

Upvotes: 1

Related Questions