module Capybara::Node::Actions

def select(value = nil, from: nil, **options)

Returns:
  • (Capybara::Node::Element) - The option element selected

Parameters:
  • from (String) -- The id, {Capybara.configure test_id} attribute, name or label of the select box
  • value (String) -- Which option to select

Overloads:
  • select(value = nil, from: nil, **options)
def select(value = nil, from: nil, **options)
  raise ArgumentError, 'The :from option does not take an element' if from.is_a? Capybara::Node::Element
  el = from ? find_select_or_datalist_input(from, options) : self
  if el.respond_to?(:tag_name) && (el.tag_name == 'input')
    select_datalist_option(el, value)
  else
    el.find(:option, value, **options).select_option
  end
end