testingember.jsember-testing

How to append an pre-filled textarea content using fillIn


I have a textarea which is already filled in with value using fillIn function. But now I want to append the same textarea with another character '@'. But when I tried using fillIn again; it rewrites the textarea. How can I append the text. I need it to be in two step process.

HTML:

<textarea data-test-id='descriptor'></textarea>

Test:

test('testing-fillIn', async function(assert){
await fillIn(testSelector('descriptor'), 'First text ');
await fillIn(testSelector('descriptor'), '@');
});

The output should be : First text @


Solution

  • test('testing-fillIn', async function(assert){
    await fillIn(testSelector('descriptor'), 'First text ');
    var textVal =document.getElementById('textArea').val();
    await fillIn(testSelector('descriptor'), textVal+'@');
    });
    <textarea id="textArea" data-test-id='descriptor'></textarea>