Skip to content
This repository has been archived by the owner on Nov 10, 2024. It is now read-only.

Latest commit

 

History

History
47 lines (33 loc) · 1.51 KB

testing-blur-events-in-cucumber-slash-capybara.org

File metadata and controls

47 lines (33 loc) · 1.51 KB

WARNING: This is old and likely obsolete.

Testing blur() events in Cucumber/Capybara

  • published date: 2016-10-10 16:18
  • keywords: [“blur”, “capybara”, “cucumber”, “focus”, “send_keys”, “steps”, “testing”, “using”]
  • source:

After banging my head on this problem for a long time, chasing blog posts, stackoverflow, lots of opinions, bug reports, and so on, I finally asked my workmates, and together we arrived at a method that works.

The Problem

There is apparently a bug, although it’s marked as INVALID in bugzilla, that prevents focus() and blur() events from being executed directly when the test browser is not focused.

The links I chased:

And many many more…

What worked

The most obviously glaring thing to do is NOT make this event happen via executing a JS script, but by simply SENDING A TAB.

Here’s the step:

When(/^I unfocus field (.*?)$/) do |field_name|
  field = page.find_field(field_name)
  field.native.send_keys :tab
end

That did the trick, and now we all have an uncle Bob.

Thanks Nic and JD