After quick research, I found two options.
field = find(target) field.native.send_keys :tab
Both worked for me, pick one you like. I prefer the first one, so what I end up is something like this:
spec/support/capybra_actions.rbmodule CapybaraActions def blur_from(locator) field = find_field(locator) field.native.send_keys :tab end end RSpec.configure do |config| config.include CapybaraActions, type: :feature end
And to use it:
scenario "Save contents automatically", :js do fill_in "post_body", with: "Long time ago..." blur_from "post_body" expect(page).to have_content("Saved") end
Tested with Capybara 3 with Headless Chrome.
Thanks to these posts:
Clap to support the author, help others find it, and make your opinion count.