Skip to content

Instantly share code, notes, and snippets.

@Hunk13
Forked from thijsc/gist:1391107
Created February 1, 2019 18:46
Show Gist options
  • Select an option

  • Save Hunk13/be70f6b52013f26dc011f1e329df1f8d to your computer and use it in GitHub Desktop.

Select an option

Save Hunk13/be70f6b52013f26dc011f1e329df1f8d to your computer and use it in GitHub Desktop.
Select item from chosen js select with Capybara and Selenium
def select_from_chosen(item_text, options)
field = find_field(options[:from])
option_value = page.evaluate_script("$(\"##{field[:id]} option:contains('#{item_text}')\").val()")
page.execute_script("$('##{field[:id]}').val('#{option_value}')")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment