diff --git a/gem/lib/capybara-select2.rb b/gem/lib/capybara-select2.rb index cb6d1d2..81f9401 100644 --- a/gem/lib/capybara-select2.rb +++ b/gem/lib/capybara-select2.rb @@ -40,7 +40,7 @@ def select2(value, options = {}) [value].flatten.each do |value| if find(:xpath, "//body").has_selector?("#{drop_container} li.select2-results__option") # 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='treeitem']", text: value).click else find(:xpath, "//body").find("#{drop_container} li.select2-result-selectable", text: value).click end