tags:

views:

17

answers:

1

In WebDriver, if I use .sendKeys it will append my string to the value that already exists in the field. I can't clear it by using .clear() because the second I do that, the webpage will throw an error saying that it has to be between 10 and 100. So I can't clear it or an error will be thrown before I can put in the new value using sendKeys, and if I sendKeys it just appends it to the value already there.

Is there anything in WebDriver that lets you overwrite the value in the field?

+1  A: 

I think you can try to firstly select all the text in the field and then send the new sequence:

element.sendKeys(Keys.chord(Keys.CONTROL, "a"), "55");
ZloiAdun
Yeah that worked, I just had to import the Keys class in. Thank you very much.
True_Blue
So maybe you will mark this as solved please? :)
ZloiAdun