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

**URL:** <https://forum.katalon.com/t/not-able-to-enter-dynamic-text-using-get-text-and-set-text-command/9372>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [February 14, 2018, 9:14am UTC](https://forum.katalon.com/t/not-able-to-enter-dynamic-text-using-get-text-and-set-text-command/9372 "2018-02-14T09:14:31Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sanni\_Patel](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@Sanni\_Patel](https://forum.katalon.com/u/Sanni_Patel)\
**Post date:** [February 14, 2018, 9:14am UTC](https://forum.katalon.com/t/not-able-to-enter-dynamic-text-using-get-text-and-set-text-command/9372/1 "2018-02-14T09:14:31Z")

</div>

Need to enter dynamic text every time the script runs

---

<div class="post-metadata">

**Author:** ![Rachel\_Bedenbaugh](https://avatars.discourse-cdn.com/v4/letter/r/c77e96/32.png) [@Rachel\_Bedenbaugh](https://forum.katalon.com/u/Rachel_Bedenbaugh)\
**Post date:** [July 6, 2018, 10:13pm UTC](https://forum.katalon.com/t/not-able-to-enter-dynamic-text-using-get-text-and-set-text-command/9372/2 "2018-07-06T22:13:35Z")

</div>

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

`http://forum.katalon.com/discussion/4423/capture-dynamically-generated-text-from-the-text-box

Also here’s a link to an article posted on Medium that could help you use XPath to check for dynamic text. [https://medium.com/@katalon\_studio/generating-reliable-object-selector-using-spy-web-utility-katalon-studio-c44e18b8d39c](https://medium.com/@katalon_studio/generating-reliable-object-selector-using-spy-web-utility-katalon-studio-c44e18b8d39c)

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [July 7, 2018, 12:06am UTC](https://forum.katalon.com/t/not-able-to-enter-dynamic-text-using-get-text-and-set-text-command/9372/3 "2018-07-07T00:06:49Z")

</div>

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

> <https://stackoverflow.com/questions/8138164/groovy-generate-random-string-from-given-character-set>

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

---

<div class="post-metadata">

**Author:** ![mvosatka](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mvosatka/32/23870_2.png) [@mvosatka](https://forum.katalon.com/u/mvosatka)\
**Post date:** [September 25, 2020, 4:42pm UTC](https://forum.katalon.com/t/not-able-to-enter-dynamic-text-using-get-text-and-set-text-command/9372/4 "2020-09-25T16:42:48Z")

</div>

Hey Andrej,

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

---

<div class="post-metadata">

**Author:** ![grylion54](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/grylion54/32/16265_2.png) [@grylion54](https://forum.katalon.com/u/grylion54)\
**Post date:** [September 25, 2020, 4:50pm UTC](https://forum.katalon.com/t/not-able-to-enter-dynamic-text-using-get-text-and-set-text-command/9372/5 "2020-09-25T16:50:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ishrat.manzoor](https://avatars.discourse-cdn.com/v4/letter/i/2bfe46/32.png) [@ishrat.manzoor](https://forum.katalon.com/u/ishrat.manzoor)\
**Post date:** [December 14, 2020, 6:38am UTC](https://forum.katalon.com/t/not-able-to-enter-dynamic-text-using-get-text-and-set-text-command/9372/6 "2020-12-14T06:38:56Z")

</div>

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’)  
WebUI.click(findTestObject('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

---

<div class="post-metadata">

**Author:** ![grylion54](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/grylion54/32/16265_2.png) [@grylion54](https://forum.katalon.com/u/grylion54)\
**Post date:** [December 14, 2020, 5:14pm UTC](https://forum.katalon.com/t/not-able-to-enter-dynamic-text-using-get-text-and-set-text-command/9372/7 "2020-12-14T17:14:04Z")

</div>

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

```auto
value = WebUI.getAttribute(findTestObject('Object 1'), 'text')
WebUI.comment('the value is:' + value)
WebUI.click(findTestObject('Object 2'))

```

> **Another way**
>
> Can you also try the following?
> 
> ```auto
> celltext = WebUI.getAttribute(findTestObject('Object 1'), 'value')
> WebUI.comment('the value is:' + celltext)
> WebUI.click(findTestObject('Object 2'))
> WebUI.setText(findTestObject('Object 2'), celltext)
> 
> ```

---

<div class="post-metadata">

**Author:** ![ishrat.manzoor](https://avatars.discourse-cdn.com/v4/letter/i/2bfe46/32.png) [@ishrat.manzoor](https://forum.katalon.com/u/ishrat.manzoor)\
**Post date:** [December 15, 2020, 5:27am UTC](https://forum.katalon.com/t/not-able-to-enter-dynamic-text-using-get-text-and-set-text-command/9372/8 "2020-12-15T05:27:31Z")

</div>

@grylion54 Here is the text that I am getting:

 ![Screenshot 2020-12-15 at 10.52.49 AM](https://europe1.discourse-cdn.com/katalon/original/2X/8/8454137e8180df17fd8dc915c0d2a6b05ef66856.png)

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.

---

<div class="post-metadata">

**Author:** ![ishrat.manzoor](https://avatars.discourse-cdn.com/v4/letter/i/2bfe46/32.png) [@ishrat.manzoor](https://forum.katalon.com/u/ishrat.manzoor)\
**Post date:** [December 15, 2020, 6:30am UTC](https://forum.katalon.com/t/not-able-to-enter-dynamic-text-using-get-text-and-set-text-command/9372/9 "2020-12-15T06:30:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![albert.vu](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/albert.vu/32/20595_2.png) [@albert.vu](https://forum.katalon.com/u/albert.vu)\
**Post date:** [August 8, 2022, 7:31am UTC](https://forum.katalon.com/t/not-able-to-enter-dynamic-text-using-get-text-and-set-text-command/9372/10 "2022-08-08T07:31:44Z")

</div>

Archived on August 8, 2022, 7:31am UTC


