Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Easiest way to select or type over text in a text box in protractor?

Tags:

protractor

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?

like image 836
Andrew Magee Avatar asked Mar 07 '14 04:03

Andrew Magee


People also ask

How do you select text with a protractor?

Key. CTRL). sendKeys('a'). perform();

How do you select all on a protractor?

Sends Ctrl+A, the keyboard shortcut for "select all".

How do you delete text in protractor?

findElement(protractor. By. input('query')); queryInput. clear(); expect(ptor.


1 Answers

I use clear to do this in one of my tests, works like a charm ;)

element(by.css("input.myInput")).clear();
like image 107
glepretre Avatar answered Sep 21 '22 15:09

glepretre