Focusout event not triggered in acceptance test


#1

I am trying to write an acceptance test that covers a component which handles the focus-out event on an input element. But nothing I do seems to trigger the event and so my subsequent action never gets sent.

In the test I have tried the following:

field = find('.profile-field').eq(0);
fillIn(field.find('input'), 'a new response');
keyEvent(field.find('input'), 'keyup', 9);  //tab out of field

or

field = find('.profile-field').eq(0);
fillIn(field.find('input'), 'a new response');
find('.profile-field').eq(1).focus();  //set focus to another field

or

field = find('.profile-field').eq(0);
fillIn(field.find('input'), 'a new response');
triggerEvent(field, "blur");

I have also tried using the click() helper on other elements on the page, but nothing seems to trigger the event.

Any suggestions on how to achieve this? Thanks


#2

On further exploration, I am seeing different behavior depending on how I run my tests. With testem in the console (ember test) the test runs successfully with Chrome but fails with PhantomJS. And if I run using the test url in the browser (localhost:4200/tests) then the behavior is inconsistent - it sometimes succeeds (i.e. the event is triggered) and sometimes not.


#3

We have found this works reliably in WebKit, but fails reliably in PhantomJS.


#4

Actually my third option above seems to work reliably for me now under PhantomJS after I realized I was incorrectly specifying the element in the initial code.

triggerEvent('<input element selector>', "blur");

#5

i love you man, you save me