{"action":"created","issue":{"url":"https://api.github.com/repos/goodwill/capybara-select2/issues/41","repository_url":"https://api.github.com/repos/goodwill/capybara-select2","labels_url":"https://api.github.com/repos/goodwill/capybara-select2/issues/41/labels{/name}","comments_url":"https://api.github.com/repos/goodwill/capybara-select2/issues/41/comments","events_url":"https://api.github.com/repos/goodwill/capybara-select2/issues/41/events","html_url":"https://github.com/goodwill/capybara-select2/issues/41","id":115774565,"number":41,"title":"`Ambiguous match` when there are multiple select2 elements","user":{"login":"dgmstuart","id":393167,"avatar_url":"https://avatars1.githubusercontent.com/u/393167?v=4","gravatar_id":"","url":"https://api.github.com/users/dgmstuart","html_url":"https://github.com/dgmstuart","followers_url":"https://api.github.com/users/dgmstuart/followers","following_url":"https://api.github.com/users/dgmstuart/following{/other_user}","gists_url":"https://api.github.com/users/dgmstuart/gists{/gist_id}","starred_url":"https://api.github.com/users/dgmstuart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgmstuart/subscriptions","organizations_url":"https://api.github.com/users/dgmstuart/orgs","repos_url":"https://api.github.com/users/dgmstuart/repos","events_url":"https://api.github.com/users/dgmstuart/events{/privacy}","received_events_url":"https://api.github.com/users/dgmstuart/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2015-11-09T01:01:11Z","updated_at":"2018-03-01T00:56:38Z","closed_at":null,"author_association":"NONE","body":"#37 changed the code which finds the select2 input from using `first` to using `find`. Unfortunately Capybara chokes when it can't find a unique element with `find` - which happens when you have more than one select2 element in the page:\n\n```\nFailure/Error: fill_event_fields_with_valid_data Capybara::Ambiguous: Ambiguous match, found 2 elements matching css \".select2-container\"\n```\n\nI don't really understand enough about the issue that #37 fixes to know what the solution should be.\n\n(cc @machisuji)\n"},"comment":{"url":"https://api.github.com/repos/goodwill/capybara-select2/issues/comments/369437438","html_url":"https://github.com/goodwill/capybara-select2/issues/41#issuecomment-369437438","issue_url":"https://api.github.com/repos/goodwill/capybara-select2/issues/41","id":369437438,"user":{"login":"mrhillman","id":32050194,"avatar_url":"https://avatars2.githubusercontent.com/u/32050194?v=4","gravatar_id":"","url":"https://api.github.com/users/mrhillman","html_url":"https://github.com/mrhillman","followers_url":"https://api.github.com/users/mrhillman/followers","following_url":"https://api.github.com/users/mrhillman/following{/other_user}","gists_url":"https://api.github.com/users/mrhillman/gists{/gist_id}","starred_url":"https://api.github.com/users/mrhillman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrhillman/subscriptions","organizations_url":"https://api.github.com/users/mrhillman/orgs","repos_url":"https://api.github.com/users/mrhillman/repos","events_url":"https://api.github.com/users/mrhillman/events{/privacy}","received_events_url":"https://api.github.com/users/mrhillman/received_events","type":"User","site_admin":false},"created_at":"2018-03-01T00:56:38Z","updated_at":"2018-03-01T00:56:38Z","author_association":"NONE","body":"I had the same issue when I had the `search: true` enabled in conjunction with another select2 element. I got the same error as above:\r\n\r\n> Capybara::Ambiguous:\r\n       Ambiguous match, found 2 elements matching css \".select2-search input.select2-search__field\"\r\n\r\nI got around this by monkey patching the gem and adding in the extra class `.select2-container--open` to the find as so\r\n\r\n```\r\nfind(:xpath, \"//body\").find(\".select2-container--open .select2-search input.select2-search__field\").set(value)\r\n```\r\n\r\nThis worked a charm for me, and haven't investigated if this extra class will work for different versions of select2 but might help others"}}
{"actor":{"display_login":"mrhillman"}}