selenium clear() command doesn't clear the element

前端 未结 8 1282
旧时难觅i
旧时难觅i 2021-01-11 21:14

I have been writing selenium scripts for a while in Java. I encountered a very weird issue today.

Here is the issue: I cleared a text field using webelement.clear()

8条回答
  •  难免孤独
    2021-01-11 21:56

    I don't know the exact reason for your element keeping its value, but you can try an alternative text clearance by sending 'Ctrl+A+Delete' key combination using sendKeys method of the element's object:

    emailAddress.sendKeys(Keys.chord(Keys.CONTROL,"a", Keys.DELETE));
    

提交回复
热议问题