Selenium sendKeys are not sending all characters

I assume this is caused by this Angular2 issue https://github.com/angular/angular/issues/5808

Angular can't process input events when they arrive too fast.

As a workaround you would need to send single characters with a small delay between each.


By using Actions class, this issue solved for me Tried many ways as mentioned above. Also tried to setvalue by js executescript Finally, found this code and it worked well for grid component built on angular

    actions.sendKeys(webElement,
    modifiedValue).perform();

I stumbled upon this error when doing integration tests with NightwatchJS (which uses selenium).

So I'm writing this for people coming here in the future.

I wrote this extension command for nightwatch:

exports.command = function (selector, value, using) {
    var self = this;
    self.elements(using || 'css selector', selector, function (elems) {
        elems.value.forEach(function (element) {
            for (var c of value.split('')) {
                self.elementIdValue(element.ELEMENT, c);
            }
        });
    });
    return this;
};

Which can be used in this way:

var username = '[email protected]';
browser.setValueSlow('input[ngcontrol=username]', username); //Works with ng2!

This issue was also discussed on NightwatchJS's github here