eliotsykes/rspec-rails-examples

CapybaraExtensions: select_then_close to close dropdown that obscures submit button

eliotsykes opened this issue · 0 comments

File: spec/support/capybara_extensions.rb

module CapybaraExtensions

  # Selects option from <select> drop down then closes the drop down.
  # Useful when a drop down obscures an element that needs to be clicked.
  def select_then_close(value, options = {})
    select(value, options)
    press_tab_key
  end

  def press_tab_key
    find('body').send_keys :tab
  end
end

RSpec.configure do |config|
  config.include CapybaraExtensions, type: :feature
end