TestProject Forum
Powered by leading experts in the test automation community

How to delete a single character from input field

I want to run a test that deletes a few characters from an input field before my assert call.

For example “Hello Sebastian” to “Hello Seba”.

How would I do so with selenium’s webdriver ?

You can use the WebElement.sendKeys method which takes an enum of any key in order to send backspace to delete a character.

element.sendKeys(Keys.BACK_SPACE);