How to clear() input fields in web?

Is there is any way to clear text from input fields in web?

1 Like

You can set the value ‘’ to the input object with the Keyword “Set Text” and the input will raplace the new value to the old one.


I need to check backspace functionality in the text field, please give solution for this?

In that case you can send a the backspace key to the input.
1.- Add a new “Web UI Keyword”
2.- Choose the keyword “Send Keys”
3.- Doubleclick on the object column and find the object that you want to send the key (they original value to your object is null)
4.- Doubleclick on the Input column. Katalon will show you a new modal with others columns.
5.- Change the value type “String” to “Keys”
6.- Doubleclick on the column value. Katalon will show you other modal and you can tap the keys directly to your keyboard or choose it/write it by yourself.

Or if you want you can copy and paste the next line to your script but you need to change the object value to a real object in your proyect.
WebUI.sendKeys(findTestObject(‘Object location’), Keys.chord(Keys.BACK_SPACE))

Let me know if it works for you :slight_smile:


WebUI.sendKeys(findTestObject(‘Object location’), Keys.chord(Keys.BACK_SPACE)), clears only a single character, is there any way to clear the string?

1 Like

WebUI.sendKeys(findTestObject(‘Object location’), Keys.chord(Keys.CONTROL, ‘a’))
WebUI.sendKeys(findTestObject(‘Object location’), Keys.chord(Keys.BACK_SPACE))
This works for me, imitates “select all” and “delete” commands…


use WebUI.clearText()


ariba_s4katalon said:

use WebUI.clearText()

WebUI.clearText() really exist ? I can find Mobile.clearText() but strangely not WebUI.clearText() …

WebUI.clearText() doesn’t work in MacOSX for webelement : //input[@type = ‘number’ and @name = ‘length’]

Have tried Command+A using Keys.chord and it doesn’t work either.
Surprisingly,everything works in Windows.

There is some workaround here:

Cool @tanmai00786 but it does not work in Mac OS for me :slightly_frowning_face:

1 Like

On Mac Os, I used:

WebUI.sendKeys(obj_repository, Keys.chord(Keys.DELETE))

It works for me

1 Like

That’s what I said, it doesn’t work in mac os x for me too. :blush: After their recent announcements of commercialisation of command line paid features, we scrapped using it anymore. Try nightwatch, cypress and Coypu atleast they are open source.

1 Like

It is not working in katalon 7.4.0

Amazing! thanks!

Perfect! Thanks

1 Like

A built-in keyword

  • WebUI.clearText(TestObject)

is available. It works just as the art of sendKeys. But unfortunately it is not documented, so nobody knows.

See also:

Here is a generic way working no matter if you are working Windows or Mac.

WebUI.sendKeys(findTestObject(‘Object location’), Keys.chord(Keys.SHIFT, Keys.ARROW_UP))
WebUI.sendKeys(findTestObject(‘Object location’), Keys.chord(Keys.BACK_SPACE))

This did the trick for me!

Hi @pranesh, :wave:

Long time no see, we hope you are doing well!

We are seeing quite a lot of discussions within your topic, and it seems that other members have proposed suitable answers to your questions. However, it would help if you could pick one out as a definitive answer by marking it as a solution :white_check_mark: by following the video below.

This way, it will help newcomers to our forum who may be having the same question as you did to reach the solution faster.

Thanks :sunglasses: