How to clear() input fields in web?

Hi,
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.

1 Like

Hi,
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:

5 Likes

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…

3 Likes

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.doubleClick(obj_repository)
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!