Module: CapybaraTestHelpers::Actions

Included in:
TestHelper
Defined in:
lib/capybara_test_helpers/actions.rb

Overview

Internal: Wraps Capybara actions to enable locator aliases, and to wrap the result with a test helper so that methods can be chained in a fluent style.

Instance Method Summary collapse

Instance Method Details

#blurObject

Public: Useful to natively blur an element.



112
113
114
115
# File 'lib/capybara_test_helpers/actions.rb', line 112

def blur
  to_capybara_node.execute_script('this.blur()')
  self
end

#focusObject

Public: Useful to natively give focus to an element.



106
107
108
109
# File 'lib/capybara_test_helpers/actions.rb', line 106

def focus
  to_capybara_node.execute_script('this.focus()')
  self
end

#type_in(*text, typing: text.size > 1 || text.first.is_a?(Symbol) || text.first.is_a?(Array), **options) ⇒ Object

Public: Sets the value for the input, or presses the specified keys, one at a time.



101
102
103
# File 'lib/capybara_test_helpers/actions.rb', line 101

def type_in(*text, typing: text.size > 1 || text.first.is_a?(Symbol) || text.first.is_a?(Array), **options)
  typing ? send_keys(*text) : set(text.first, **options)
end