Set Text with a random Text.


#1

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.


#2

Take a look at the apache APIs:

import org.apache.commons.lang.RandomStringUtils


#3

This might be useful, too:

https://commons.apache.org/proper/commons-lang/javadocs/api-release/index.html


#4

Russ Thomas said:

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’)


#5

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


#6

Avinash Motwani said:

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))


#7

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.


#8

I did below and working fine :slight_smile:

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

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