jeudi 20 juillet 2017

Pressing Enter in textarea using jQuery and Ember test selector

In an acceptance test, pressing Enter key after text input triggers an event. I tried to fillIn text and hit enter with the keyEvent. PS: I used ember test selector plugin for data-test-id. Please help why the keyEvent is not running. Testem ignores the keyEvent. jQuery solutions are also encouraged.

HTML:

<div class="issue-container">
<div class="create-container">
<div id="ember13" class="input-field ui-textarea md-animated ember-view">
<label id="ember1369-label" for="ember1369-input" class="">Add an issue</label>
<textarea data-test-id="txtid" id="ember1369-input" class="md-textarea" style="height: 21.5px; overflow: hidden;"></textarea></div></div></div>

Acceptance test:

test('review-an-element', async function(assert) {
await fillIn(testSelector('txtid'), 'Input is typed here and then hit enter');
await keyEvent(testSelector('txtid'), 'keypress', 13);});

My jQuery attempt:

var e = jQuery.Event("keypress");
e.which = 13;
e.keyCode = 13;    
await $('.md-textarea').trigger(e);




Aucun commentaire:

Enregistrer un commentaire