Created
November 24, 2011 11:08
-
-
Save thijsc/1391107 to your computer and use it in GitHub Desktop.
Select item from chosen js select with Capybara and Selenium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
To guarantee an exact match rather than a partial match aka - find 'OR' and not match 'MORE'
replace
the line
with