Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intermittent issues triggering events on elements with bound actions #193

Closed
robmonie opened this issue Sep 29, 2015 · 6 comments
Closed

Comments

@robmonie
Copy link

We've been experiencing an intermittent issue with triggering focus events on inputs within Ember acceptance tests. Sometimes the events trigger and sometimes they don't. This problem occurs with the various helpers such as click('.my-class'), triggerEvent('.my-class', 'focus') or when do this long hand via something like...

andThen(function(){
  Ember.run(function() {
    find('.my-class').focus();
  });
});

The following test app demonstrates this in isolation. See the readme for info about how to run the tests and increase your chances of the problem occurring.

https://github.com/robmonie/test-event-trigger

The tests also include tests against click events on a button that always pass.

Any thoughts on this would be much appreciated. I'd be very happy to find out i'm doing something incorrectly to cause this. If you think there's a better place to raise this, please let me know.

@v-shan
Copy link

v-shan commented Aug 10, 2016

Hi @robmonie we're experiencing the exact same issues (triggers sometimes, often fails when running via testem in parallel with phantomjs). Did you ever figure it out?

@robmonie
Copy link
Author

Hi @v-shan. I'm pretty sure we gave up and worked around this by not triggering focus on the input in our tests but instead triggering a click which has the side effect of focusing the input.

@v-shan
Copy link

v-shan commented Aug 29, 2016

Thanks @robmonie - we were able to work around this by using triggerHandler instead

@robmonie
Copy link
Author

robmonie commented Sep 1, 2016

Thanks for the follow up @v-shan. You've actually reminded me of the real reason this wasn't working for us. We noticed that it was due to the browser window not being in focus sometimes when running the tests. When this is the case, the focus/blur events don't fire on the elements being tested.

@v-shan
Copy link

v-shan commented Sep 1, 2016

@robmonie makes sense- I think we had the same issue. With triggerHandler, "the browser's default focus action would not be triggered, only the event handlers bound to the focus event".

@Turbo87
Copy link
Member

Turbo87 commented Oct 14, 2017

I'd recommend to use the focus() helper of https://github.com/cibernox/ember-native-dom-helpers and test in a real browser like headless Chrome because phantom has some known issues with focusing.

@Turbo87 Turbo87 closed this as completed Oct 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants