How can I clear the value value of the input box? I try to use cleartext, but the original value is still there after saving

How can I clear the value value of the input box? I try to use cleartext, but the original value is still there after saving

I need to see the HTML/DOM – please take a screenshot of the Inspector in DevTools.

Also, post the Test Case code you are using.

Thanks.

As Russ said, we will need to see the HTML of the field you are trying to clear. Aside from that, I can tell you that WebUI.clearText() (which ultimately uses Selenium’s clear() method) is notoriously flakey, particularly with alternate implementations of text fields. Otherwise, if it’s your standard <input> element, it tends to work fine.

The best way to handle clearing text across the board is to select all the text in the field, then send a backspace or delete key. Unfortunately, as far as I know, the first part of that task is not currently doable with the WebUI.sendKeys() method (see this topic). Here’s how you could do it with Selenium though:

import org.openqa.selenium.*
import com.kms.katalon.core.webui.common.WebUiCommonHelper

WebElement element = WebUiCommonHelper.findWebElement(findTestObject('path/to/object'), 30);
element.sendKeys(Keys.chord(Keys.CONTROL, 'a'));
element.sendKeys(Keys.DELETE);

And what is the xpath you are using to your element?

@1968693027 you might find this useful when working with webpage elements:

import org.openqa.selenium.*
import com.kms.katalon.core.webui.common.*

WebElement element = DriverFactory.getWebDriver().findElement(By.xpath("//input[@id='qa-test-deploy-underlay-new-upMbps-input']"));
element.sendKeys(Keys.chord(Keys.CONTROL, 'a'));
element.sendKeys(Keys.DELETE);
1 Like