Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I sendKeys to a ui-ace instance with Protractor?

I want to test some keypresses against a ui-ace instance. However, Protractor can't get focus on the ace element. Ace includes a <textarea> that I can get focus on (and thus send keys to) but ui-ace doesn't recognize keys inputted there (and subsequently doesn't update the model).

Selecting method (by.model, etc) has no impact.

My current workaround is to use evaluate to set the scope value manually, but this breaks the point of using Protractor.

like image 203
SomeKittens Avatar asked Jan 10 '23 21:01

SomeKittens


1 Answers

Good question! Seems that the workaround is double clicking first.

The following works at least on Chrome:

"use strict";
describe('Testing ui-ace', function() {
    var divInput = $('div.ace_content');
    var inputElm = $('textarea.ace_text-input');

    it('opens a ui-ace page', function() {
        browser.ignoreSynchronization = true;  // sorry but no angular page
        browser.get('http://angular-ui.github.io/ui-ace/');
        browser.sleep(3000); // sorry but no angular page
    });

    it('starts editing', function() {
        browser.actions().doubleClick(divInput).perform();
    });

    it('enters some text', function() {
        inputElm.sendKeys('Hola');
        browser.sleep(5000); // to let you see the result
    });
});
like image 109
Leo Gallucci Avatar answered Jan 18 '23 20:01

Leo Gallucci