In a protractor test I have an <input type="text"/>
that is pre-filled with a value, and I'd like to erase that value and type a new one. Ideally I'd be able to just say something like
// Some way to select all the text in the text box so `
// sendKeys` will type over it.
element(by.css("input.myInput")).selectAll();
element(by.css("input.myInput")).sendKeys("my new value");
But selectAll
doesn't exist and I can't find anything helpful in the API docs.
Any ideas?
Key. CTRL). sendKeys('a'). perform();
Sends Ctrl+A, the keyboard shortcut for "select all".
findElement(protractor. By. input('query')); queryInput. clear(); expect(ptor.
I use clear
to do this in one of my tests, works like a charm ;)
element(by.css("input.myInput")).clear();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With