Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Chosen Select Capybara Helper
def chooze_from original_field_selector, *selected_values
original_field = find original_field_selector
original_field_id = original_field[:id]
container_selector = "##{ original_field_id }_chzn"
container = find container_selector
if container[:class].include? 'chzn-container-multi'
activator = find "#{ container_selector } .chzn-choices"
else
activator = find "#{ container_selector } .chzn-single"
end
selected_values.each do |value|
activator.click
find("#{ container_selector } .chzn-results li", text: value).click
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment