Hi there,
I have been trying to delete(clear) text in an input field. But I could not find a solution which works on all browsers. I am using MacBook air. So far I tried all the below
// This introduces weird symbols in Firefox
WebUI.doubleClick(findTestObject(‘OR/Input_field’))
WebUI.sendKeys(findTestObject(‘OR/Input_field’), Keys.chord(Keys.BACK_SPACE))
//set text empty string work in Firefox not in chrome
WebUI.setText(findTestObject(‘OR/Input_field’), ’ ')
//Clear text not working in chrome, it just appends next string to the previous one without erasing it.
WebUI.clearText(findTestObject(‘Patient/Page_E-Besok_Patient/Child/Input_Child_SSN’))
//DELETE is not working as well
WebUI.click(findTestObject(‘OR/Input_field’))
WebUI.WebUI.sendKeys(findTestObject(‘OR/Input_field’), Keys.DELETE)
Also tried the keyword
@Keyword
def static clearElementText(TestObject to) {
WebElement element = WebUiCommonHelper.findWebElement(to,GlobalVariable.Timeout)
WebUI.executeJavaScript(“arguments[0].value=‘’”, Arrays.asList(element))
}
Tried the key events
Robot rb = new Robot()
WebUI.delay(1)
rb.keyPress(KeyEvent.VK_BACK_SPACE)
WebUI.delay(1)
rb.keyRelease(KeyEvent.VK_BACK_SPACE)
Is there any other solution that works on all browsers and machines?