# Add numbers in field

**URL:** <https://forum.katalon.com/t/add-numbers-in-field/58357>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [September 16, 2021, 12:47pm UTC](https://forum.katalon.com/t/add-numbers-in-field/58357 "2021-09-16T12:47:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bounce322](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/bounce322/32/16104_2.png) [@bounce322](https://forum.katalon.com/u/bounce322)\
**Post date:** [September 16, 2021, 12:47pm UTC](https://forum.katalon.com/t/add-numbers-in-field/58357/1 "2021-09-16T12:47:02Z")

</div>

Hello!  
have one problem on my webpage there is field which can be filled only with digits, it is ID.

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/9/e/9e9124dfa166a5f37b4efa2e044869a3ec756201.png)

The problem is that i need to enter every time different ID number, so i need to randomly generate it and fill into my form.  
here is my code example

```auto
int randomDigits
randomDigits = (Math.random()*10000000000)
int a=randomDigits
WebUI.click(findTestObject('Object Repository/step1/id_card_number'))
WebUI.setText(findTestObject('Object Repository/step1/id_card_number'), randomDigits )
WebUI.setText(findTestObject('Object Repository/step1/id_card_number'), '1234' )
WebUI.sendKeys(findTestObject('Object Repository/step1/id_card_number'), Keys.chord('1234'))

```

```auto
WebUI.setText(findTestObject('Object Repository/step1/id_card_number'), randomDigits )

```

this part throw error

```auto
2021-09-16 15:21:39.284 DEBUG testcase.Registration_full - 15: setText(findTestObject("Object Repository/step1/id_card_number"), randomDigits)
2021-09-16 15:21:39.354 ERROR c.k.katalon.core.main.TestCaseExecutor - ❌ Test Cases/Registration/Registration_full FAILED.
Reason:
groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.setText() is applicable for argument types: (com.kms.katalon.core.testobject.TestObject, java.lang.Integer) values: [TestObject - 'Object Repository/step1/id_card_number', 344799900]
Possible solutions: setText(com.kms.katalon.core.testobject.TestObject, java.lang.String), getText(com.kms.katalon.core.testobject.TestObject), getText(com.kms.katalon.core.testobject.TestObject, com.kms.katalon.core.model.FailureHandling), setText(com.kms.katalon.core.testobject.TestObject, java.lang.String, com.kms.katalon.core.model.FailureHandling), clearText(com.kms.katalon.core.testobject.TestObject), clearText(com.kms.katalon.core.testobject.TestObject, com.kms.katalon.core.model.FailureHandling)
	at Registration_full.run(Registration_full:45)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:398)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:389)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:368)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:360)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:255)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1631794877786.run(TempTestCase1631794877786.groovy:25)

```

but other two settext and sendkeys to nothing.

Can someone help me with this issue. I need somehow take random 10 digits (only integer) and put in into my field

---

<div class="post-metadata">

**Author:** ![kenzie.rigole](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kenzie.rigole/32/22830_2.png) [@kenzie.rigole](https://forum.katalon.com/u/kenzie.rigole)\
**Post date:** [September 16, 2021, 12:51pm UTC](https://forum.katalon.com/t/add-numbers-in-field/58357/2 "2021-09-16T12:51:33Z")

</div>

you need to call .toString() on the randomDigits

---

<div class="post-metadata">

**Author:** ![bounce322](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/bounce322/32/16104_2.png) [@bounce322](https://forum.katalon.com/u/bounce322)\
**Post date:** [September 16, 2021, 1:48pm UTC](https://forum.katalon.com/t/add-numbers-in-field/58357/3 "2021-09-16T13:48:38Z")

</div>

> [@kenzie.rigole](#):
>
> .toString()

```auto
WebUI.click(findTestObject('Object Repository/step1/id_card_number'))
WebUI.setText(findTestObject('Object Repository/step1/id_card_number'), randomDigits.toString() )

```

tried like this, no error but the field did not filled with digits, stays empty.

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/9/5/955c946991ee6b842724300daadce003c61cc574.png)

---

<div class="post-metadata">

**Author:** ![kenzie.rigole](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kenzie.rigole/32/22830_2.png) [@kenzie.rigole](https://forum.katalon.com/u/kenzie.rigole)\
**Post date:** [September 16, 2021, 2:01pm UTC](https://forum.katalon.com/t/add-numbers-in-field/58357/4 "2021-09-16T14:01:51Z")

</div>

there’s several reasons that COULD cause this  
one would be that your xpath is wrong(and not selecting the correct input), you should verify that first  
another possibility is that the input is cleared afterward(could be as a result from you clicking on it)  
another could be because of the validation on that field that clears it under wrong input

what you should do is, first, do everything manually, with correct data so you can go to the next step  
then try to replicate that exact input through automation  
and THEN you should look into randomizing the input

if you still can’t find the solution, it would be helpful to share the selection method and the selector, as defined in katalon for the testobject

---

<div class="post-metadata">

**Author:** ![bounce322](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/bounce322/32/16104_2.png) [@bounce322](https://forum.katalon.com/u/bounce322)\
**Post date:** [September 16, 2021, 2:21pm UTC](https://forum.katalon.com/t/add-numbers-in-field/58357/5 "2021-09-16T14:21:45Z")

</div>

found a workaround, if I paste ID in another field with ‘-’ signs and then send key CTRL+A ,CTRL+C, i can paste it in card id field

```auto
int random_7_Digits
random_7_Digits = (Math.random()*10000000)
//generate random id number
id_number = '13-'+ random_7_Digits + '-1'
//copy the id number into mail and paste in id field
WebUI.setText(findTestObject('Object Repository/step1/mail'), id_number)
WebUI.sendKeys(findTestObject('Object Repository/step1/mail'), Keys.chord(Keys.CONTROL, 'a'))
WebUI.sendKeys(findTestObject('Object Repository/step1/mail'), Keys.chord(Keys.CONTROL, 'c'))
WebUI.click(findTestObject('Object Repository/step1/id_card_number'))
WebUI.sendKeys(findTestObject('Object Repository/step1/id_card_number'), Keys.chord(Keys.CONTROL, 'v'))

```

here is atribute settings

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/4/c/4c6a4e7337cfd1b40528b38e73033e6768f7c5c2.jpeg)

very strange why i cant just type text in field, first time i see this kind of fields

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [September 16, 2021, 2:29pm UTC](https://forum.katalon.com/t/add-numbers-in-field/58357/6 "2021-09-16T14:29:07Z")

</div>

Try `sendKeys()` for the whole string of characters. Some input controls need to “sense” keypresses.
