Alex Jack
Katalon Apprentice
07/11/2018

How to call value inside global variable type range

Hi,

I want ask about how to call value inside global variable type range

I have create global variable

RandomNumber [1..999]

but when I call the global variable, Globalvariable.RandomNumber, the result displayed 1..999 not pick the random value range
Upvote
Quote

Comments

  • Andrej Podhajský
    Katalon Evangelist
    07/11/2018
    hmmm i think what you defined is global variable with name "RandomNumber" defined as range 1..999. am i right?
    you can use this range to pass it to some function that will generate random no. from that range.
    Upvote
    Quote
  • Marek Melocik
    Katalon Expert
    07/11/2018
    edited July 11
    Ugly, but working solution:

    IntRange ir = GlobalVariable.RandomNumber
    int randomNumber = ir.get(new Random().nextInt(ir.getTo() - ir.getFrom() + 1) + ir.getFrom())
    Upvote
    Quote
  • Alex Jack
    Katalon Apprentice
    07/11/2018
    hmmm i think what you defined is global variable with name "RandomNumber" defined as range 1..999. am i right?
    you can use this range to pass it to some function that will generate random no. from that range.
    yes it is global variable type range



    I have tried to call global variable by type 'Globalvariable.RandomNumber', but it give result '1..9999', not a random number between 1 and 9999

    Upvote
    Quote
  • Andrej Podhajský
    Katalon Evangelist
    07/11/2018
    edited July 11
    ok, again ... it's jut range ... there is no function behind that will pick anything ... just definition of range ... look at @Marek Melocik solution

    @Marek - Upvote from me
    Upvote
    Quote
  • Alex Jack
    Katalon Apprentice
    07/12/2018
    OK thx
    Upvote
    Quote
Sign In or Register to comment.