Skip to content

Instantly share code, notes, and snippets.

@dzaporozhets
Forked from thijsc/gist:1391107
Created October 30, 2012 15:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dzaporozhets/3981157 to your computer and use it in GitHub Desktop.
Save dzaporozhets/3981157 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