Skip to content

Instantly share code, notes, and snippets.

@bbonamin
Forked from thijsc/gist:1391107
Created June 18, 2012 15:59
Show Gist options
  • Save bbonamin/2949093 to your computer and use it in GitHub Desktop.
Save bbonamin/2949093 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
@bbonamin
Copy link
Author

Working great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment