Search code examples
geb

WebElement clear function doesn't clears the input values in some cases


I'm setting up a geb automation front-end test which requires me to clear the input values and set new values. I use WebElement clear method but it works for some input element but doesn't for some.

I use following code as a work around which may be a poor hack

 def length = InputElement.value().toString().length()
        while(length-- > 0){
            InputElement.firstElement().sendKeys(Keys.BACK_SPACE)
        }

Is there any better way to achieve the same functionality?


Solution

  • You should be able to set the input.value = ""