How to clear() input fields prior to populating them?

Hi all,

Is there a way to delete a text from an input field prior to populating that again ?

In Selenium WebDriver we use something like:driver.find_element_by_id(‘foo’).clear()

Is there a way to do that in Katalon Studio ?

Thanks!

Thanks a lot! Much appreciated!

Hi there,

clear() function can also be achieved in Katalon Studio in just one statement, e.g:

import com.kms.katalon.core.webui.common.WebUiCommonHelper
WebUiCommonHelper.findWebElement(findTestObject('Page_Login/txt_UserName'), 30).clear()

There are many functions from WebUiCommonHelper, you can take a look at that too

For now I found only one way to get rid of a text in an input field is by using ‘sendKeys’ but would appreciate if you can add the clear() function also.

Here it is:

make sure you import what is needed for that
import org.openqa.selenium.Keys as Keys

Now, here is the 2 lines of code that would better be replaced by one line clear():

WebUI.sendKeys(findTestObject(‘FieldA’), Keys.chord(Keys.CONTROL, ‘a’))

WebUI.sendKeys(findTestObject(‘FieldA’), Keys.chord(Keys.DELETE))