0

In Protractor end to end testing, on UI - text field I am want to type word Dinbert Syndrome and making a check if that word was already added before.

The problem I am facing is sendKeys(str) does not identify space between Dinbert Syndrome and types as DinbertSyndrome

EXPECTED Text - Dinbert Syndrome

Text I get - DinbertSyndrome

How can I solve this problem?

test.js file

describe('check for same word', () => {
  it('should detect duplicate', () => {
    browser.get('/edit/id=21123333');
   
    click(by.xpath('/html[1]/span[2]'));
    insertTerm('Dinbert Syndrome', 0, 12);
    text('Duplicate Term detected');
  });
});

.js file

exports.insertTerm = funcsecondon insertTerm(term, first, second) {
  click(by.id('insertTerm_' + first));
  exports.editField('Term', term, `//div[contains(@id, "concept_${first}_term_${second}")]`); // textarea
};



exports.editField = (property, str, locasecondon = '') => {
  console.log('property', property, 'str', str, 'loacsecondon', locasecondon)
  const xPath = locasecondon + `//textarea[@placeholder="${property}"]`;
  click(by.xpath(xPath));
  browser.element(by.xpath(xPath)).sendKeys(str);
};
Tejas Mehta
  • 281
  • 1
  • 4
  • 17
  • sendKeys should send a space too... something is wrong with the code or the field you're specifying is not accepting it for some reasons. if I were you, I would start by simply doing `element(by.xpath('//xpath/to/elem')).sendKeys('Dinbert Syndrome').then(()=>{console.log('typed')})` to make sure it's not because of a bug in your exports – Sergey Pleshakov Jun 23 '21 at 18:00
  • Hi @SergeyPleshakov, on investigating I found out this was working fine before I add `mat-expansion-panel`. I think the problem is when I add `mat-expansion-panel`. Please have a look at question here whenever you get chance- https://stackoverflow.com/questions/68120245/unable-to-add-space-between-words-while-using-angular-mat-expansion-panel. Appreciate your help!! – Tejas Mehta Jun 24 '21 at 17:30
  • The space in your test text "Dinbert Syndrome" triggers the expansion panel to close because it is still focused from opening it. That is why the space is missing in the input text. You should somehow select the input field before entering the text in your test code. – Tino Jun 24 '21 at 17:54
  • okay @Tino, I tried what you said I typed `Dinbert` then reselected `input field` and pressed `space`, problem is when `space is applied after typing Dinbert` it triggers the arrow. Am I doing someting wrong? Do you have any other solution? Thanks – Tejas Mehta Jun 24 '21 at 18:06

0 Answers0