diff --git a/gem/lib/capybara-select2.rb b/gem/lib/capybara-select2.rb index cb6d1d2..f6b8aad 100644 --- a/gem/lib/capybara-select2.rb +++ b/gem/lib/capybara-select2.rb @@ -38,9 +38,9 @@ def select2(value, options = {}) end [value].flatten.each do |value| - if find(:xpath, "//body").has_selector?("#{drop_container} li.select2-results__option") + if find(:xpath, "//body").has_selector?("#{drop_container} li.select2-results__option[role$=group]") # select2 version 4.0 - find(:xpath, "//body").find("#{drop_container} li.select2-results__option", text: value).click + find(:xpath, "//body").find("#{drop_container} li.select2-results__option[role$=group]", text: value).click else find(:xpath, "//body").find("#{drop_container} li.select2-result-selectable", text: value).click end