Passing a Set Text Value

WebUI.setText(findTestObject(‘Object Repository/Page_Test/input_Ok_name’), ‘Sanity_Check’+ RandomStringUtils.randomNumeric(2))

I want to use the above random text value in the next test case, in the next screen to search this and see the status.

How to achieve? Can you help me?

personally, i’ve been using a singleton class to store everything which i need to verify in a next step, there are probably better solutions if you don’t have a lot of data you pass, such as storing it in a globalvariable

Thanks ,Do you have any sample code or screenshots.I am new to Katalon still learning.

@Singleton
class MyVariables {
private String someVariable="";
}

public static String getSomeVariable(){
return MyVariables.getInstance().someVariable
}

public static String setSomeVariable(String newValue){
MyVariables.getInstance().someVariable=newValue
}


then in any step definition where i need it, i just call
Variables.getSomeVariable()
Variables.groovy being the file containing the code above
it’s been working great for me so far

Sorry,I am not getting this one and I am not good at coding.

Basically
I am setting the below random text in a text box in screen 1
WebUI.setText(findTestObject(‘Object Repository/Page_Test/input_Ok_name’), ‘Sanity_Check’+ RandomStringUtils.randomNumeric(2))

I need to use the same above random text in the screen 2 using set text .

Can you pls give me steps and the place in detail.

I assume you are putting the text into an input tag. I think you could do something like:

def radValue = RandomStringUtils.randomNumeric(2);

WebUI.setText(findTestObject('Page_Test/input_Ok_name'), 'Sanity_Check'+ radValue.toString())
"verify the text was put in the field"
WebUI.verifyMatch(WebUI.getAttribute(findTestObject('Page_Test/input_Ok_name'), "value"), 'Sanity_Check'+ radValue.toString(), false)

If you are wanting to reuse the radValue, now you can put it into another text element. If you want to use the radValue in other TestCases, then you have to put it into a GlobalVariable (String).

GlobalVariable.radValue = RandomStringUtils.randomNumeric(2).toString();

This worked for me,Thanks a lot!