I would like to use .sendKeys() to enter text in the input field, and then back one character. I tried using the following code with .sendKeys(protractor.Key.BACK_SPACE) , but it looks like it clears the entire field.
My test:
describe('backspace', function() { it('types some stuff and backspaces one character', function() { element(by.model('invoice.customerName')).sendKeys('Ali Khoda'); element(by.model('invoice.customerName')).sendKeys(protractor.Key.BACK_SPACE); expect(element(by.model('invoice.customerName')).getText()).toBe('Ali Khod'); }); });
Error: Expected '' to be 'Ali Khod'.
Is there a way to overlap just one character?
UPDATE:
I also tried the following, since .sendKeys() returns the default promise.
describe('backspace', function() { it('types some stuff and backspaces one character', function() { element(by.model('invoice.customerName')).sendKeys('Ali Khoda').then(function() { element(by.model('invoice.customerName')).sendKeys(protractor.Key.BACK_SPACE).then(function() { expect(element(by.model('invoice.customerName')).getText()).toBe('Ali Khod'); }); }); }); });
The test does not work exactly the same.
source share