Thiago Morais
Katalon Apprentice
03/08/2018

Set Text with a random Text.

Hello Guys,
A long time ago when I used the selenium IDE I remember that was possible to set a text + random text or number, Is possible to do it on Katalon? and if possible how do I do that?
Example: Comand = Set Text, Object = X, Input =  " Name+random value".
Thanks. 
Tagged:
Upvote
Quote

Comments

  • Russ Thomas
    Katalon Expert
    03/08/2018
    Take a look at the apache APIs:

    import org.apache.commons.lang.RandomStringUtils


    Upvote
    Quote
  • Russ Thomas
    Katalon Expert
    03/08/2018
  • Thiago Morais
    Katalon Apprentice
    03/08/2018
    edited March 8
    Take a look at the apache APIs:

    import org.apache.commons.lang.RandomStringUtils


    and how i use it on Katalon? I go to the script of my test case and insert it and how i use the random function on my command?

    my current command is:
    WebUI.setText(findTestObject('Page_CreateEvent/input_title1'), 'Event Draft Automation 02')


    Upvote
    Quote
  • Avinash Motwani
    Katalon Apprentice
    03/12/2018
    edited March 12
    Simply import ->
    import org.apache.commons.lang.RandomStringUtils

    Type below and run --- >

    System.out.println("Random===>"+RandomStringUtils.randomNumeric(5))  // replace any number by 5

    Then Check console 
    Upvote
    Quote
  • Thiago Morais
    Katalon Apprentice
    03/13/2018
    Simply import ->
    import org.apache.commons.lang.RandomStringUtils

    Type below and run --- >

    System.out.println("Random===>"+RandomStringUtils.randomNumeric(5))  // replace any number by 5

    Then Check console 
    Very Thanks, This worked for me, my command was like this
    WebUI.setText(findTestObject('Page_CreateEvent/input_title1'), 'Event Draft Automation 02' + RandomStringUtils.randomNumeric(5))

    Upvote
    Quote
  • Jeffrey Kemble
    Katalon Apprentice
    04/26/2018
    Use test data from within excel. Create an excel file, within one or many of the columns write formulas for random data. Each time it's called in Katalon it will be random. e.g. ="helloworld"&" "&randbetween(0,99) will get you helloworld 0-99 randomly... You can get way more complex and creative inside of excel then with group/list names randomized etc.
    Upvote
    Quote
  • Himani
    Katalon Apprentice
    05/23/2018
    I did below and working fine :)

    def username = org.apache.commons.lang.RandomStringUtils.randomAlphanumeric(StringSize)

    WebUI.setText(findTestObject('Registration/input_np-username'),username)


    Upvote
    Quote
Sign In or Register to comment.