goodwill / capybara-select2

Helper for capybara to be able to trigger select on select2 javascript (needed for js enabled test only)
MIT License
80 stars 111 forks source link

Add support for lists with `<optgroup>`'s #28

Closed jayschab closed 10 years ago

jayschab commented 10 years ago

When translating a list with <optgroup>'s select2 will use the following structue:

div.select2-drop
  ul.select2-results
    li.select2-result.select2-result-unselectable
      div
      ul.select2-result-stub
        li.select2-result.select2-result-selectable
        li.select2-result.select2-result-selectable
        ...
    li.select2-result.select2-result-unselectable
    ...

The old "#{drop_container} li" selector would lead to Capybara::Ambiguous error complaining that:

Ambiguous match, found 2 elements matching css ".select2-drop li" with text "..."

because of the additional <li> at the optgroup level.

This change adds a selector for "select2-result-selectable" to ignore such headers.