How to enter one backspace using the Transporter?

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.

+5
source share
1 answer

The workaround I found is the following:

expect(element(by.model('invoice.customerName')).getAttribute('value')).toBe('Ali Khod');

Instead of using .getText() I used .getAttribute('value') .

0
source

Source: https://habr.com/ru/post/1209863/


All Articles