spec/support/helper_methods.rb
# Allow running system specs with JS enabled and still access 'chosen' select inputs
Allow running system specs with JS enabled and still access 'chosen' select inputs
Allow running system specs with JS enabled and still access ' chosen ' select inputs
def select_from_chosen(item_text, options)
  field = find_field(options[:from], visible: false)
  option_value = page.evaluate_script("$(\"##{field[:id]} option:contains('#{item_text}')\").val()")
  page.execute_script("value = ['#{option_value}']\; if ($('##{field[:id]}').val()) {$.merge(value, $('##{field[:id]}').val())}")
  option_value = page.evaluate_script("value")
  page.execute_script("$('##{field[:id]}').val(#{option_value})")
  page.execute_script("$('##{field[:id]}').trigger('chosen:updated')")
end
def select_from_chosen ( item_text , options ) field = find_field ( options [ :from ] , visible : false ) option_value = page . evaluate_script ( "$(\"##{field[:id]} option:contains('#{item_text}')\").val()" ) page . execute_script ( "value = ['#{option_value}']\; if ($('##{field[:id]}').val()) {$.merge(value, $('##{field[:id]}').val())}" ) option_value = page . evaluate_script ( "value" ) page . execute_script ( "$('##{field[:id]}').val(#{option_value})" ) page . execute_script ( "$('##{field[:id]}').trigger('chosen:updated')" ) end
Allow running system specs with JS enabled and still access 'chosen' select inputs
Allow running system specs with JS enabled and still access ' chosen ' select inputs
item_text
<not_specific>
options
<not_specific>