class Capybara::RackTest::Form

def params(button)

def params(button)
  params = make_params
  form_element_types = %i[input select textarea]
  form_elements_xpath = XPath.generate do |xp|
    xpath = xp.descendant(*form_element_types).where(!xp.attr(:form))
    xpath += xp.anywhere(*form_element_types).where(xp.attr(:form) == native[:id]) if native[:id]
    xpath.where(!xp.attr(:disabled))
  end.to_s
  native.xpath(form_elements_xpath).map do |field|
    case field.name
    when 'input' then add_input_param(field, params)
    when 'select' then add_select_param(field, params)
    when 'textarea' then add_textarea_param(field, params)
    end
  end
  merge_param!(params, button[:name], button[:value] || '') if button[:name]
  params.to_params_hash
end