Not able to enter dynamic text using get text and set text command

Need to enter dynamic text every time the script runs

Is it possible to solve this by creating a variable that links to your csv or other source of dynamic text? Then call that variable for use in your test case scripts.

Test for the attribute value, this way its searching for a dynamic value versus static text. `attribute = WebUI.getAttribute(findTestObject(....), 'value')


Also here’s a link to an article posted on Medium that could help you use XPath to check for dynamic text.

ok, so i put “generate random text in groovy” to google and here is some solution:

hope this is what you are looking for because header of this post does not correspond with question you asked.

1 Like

Hey Andrej,

how to put this definition into the Katalon script mode ?
Binary statement or method call statement ?

How often are you going to use the randomString method? If more than once, put it in a Keyword.

This is not working for me too. Please help
I need to enter a dynamic text in the search field, every time I run the test script.
I have used both get text and get attribute, I am getting the value successfully. However, when the set the same text in the search, my script fails.

value = WebUI.getAttribute(findTestObject(‘Object 1’), ‘text’)'Object 2))
WebUI.setText(findTestObject(‘Object 2’), value)

It doesn’t start typing the field and fails. Please help me how to fix it. Thanks

@ishrat.manzoor Can I suggest that you print out the value contents to see if you actually have got the text.

value = WebUI.getAttribute(findTestObject('Object 1'), 'text')
WebUI.comment('the value is:' + value)'Object 2'))
Another way

Can you also try the following?

celltext = WebUI.getAttribute(findTestObject('Object 1'), 'value')
WebUI.comment('the value is:' + celltext)'Object 2'))
WebUI.setText(findTestObject('Object 2'), celltext)

@grylion54 Here is the text that I am getting:

I tried the another way too but the Value is coming as null. And I simply want the text(label) of the element on which I am clicking and search with that text.

Hey it worked, my bad I wasn’t actually giving the proper Test object. So the value was coming up with the question marks which wasn’t working in Set text.
Fixed it now…Thank you so much