goodwill / capybara-select2 Goto Github PK
View Code? Open in Web Editor NEWHelper for capybara to be able to trigger select on select2 javascript (needed for js enabled test only)
License: MIT License
Helper for capybara to be able to trigger select on select2 javascript (needed for js enabled test only)
License: MIT License
Looked at the code and seems it is not supported currently.
Hi Everyone,
I've used this gem to test on select2-rails. When I ran my spec, It raises error "undefined method 'find' for nil:NilClass ".
Anyone has any idea about this error.
Thanks in advance & Regards,
Bunhok
The last version was released almost a year ago, while the current master has useful improvements, such as select2 4.0 support. I am currently using a github ref, which works fine, but an official release would be nicer. Is there something that should still be fixed first?
First off, I love this gem!!! I am having issues with the tests timing out. I have added in sleep 2's before and after the action button clicks but it is still hanging up during tests basically after it prints out:
Any ideas?
BR
Dear Goodwill,
Currently, I got an new error "Capybara::Webkit::ClickFailed".
Do you have any idea about this error?
Thanks & Regards,
Bunhok
Hi, I'm trying to use this gem at my project, but when I put this in my spec it returns this error:
Capybara::Poltergeist::MouseEventFailed:
Firing a click at co-ordinates [188, 135] failed.
Poltergeist detected another element with CSS selector 'html body div#select2-drop-mask.select2-drop-mask' at this position.
It may be overlapping the element you are trying to interact with.
If you don't care about overlapping elements, try using node.trigger('click').
my files:
select2_spec.rb:
#...a lot of anothers specs...
select2(@kuririn.email, from: 'User')
expect(page).to_not have_content @goku.email
expect(page).to have_content @kuririn.email
view.html.erb
<%= simple_form_for :filter, url: 'filter', method: 'get', html: {class: 'form-inline' } do |f| %>
<label for="user_id">User</label>
<%= f.input_field :user_id, collection: @project.users, as: :select,
value_method: :id,
label_method: :email,
class: "select_users_by_select2" %>
<% end %>
<% @users.each do |user| %>
<%= user.email %>
<% end %>
I have two select2 Unit
and Unit Type
when I do
select2 "ABC", from: "Unit"
Then I got error
Ambiguous match, found 2 elements matching visible css "label:not(.select2-offscreen)" with text "Unit"
It need an option to find exact text
When using :css
or :xpath
, you have to know the selector for the container, which is dependent on the implementation of select2. It would be better if you could define a selector for the oriinal element on which the select2 is applied, since that on is quite well know to the developer, and independent of inplementation changes of select2.
If you wish, I can create a PR...
The current rubygems gem is versioned at 0.0.8 but master has lots of fixes and is versioned at 1.0.0.
#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:
Failure/Error: fill_event_fields_with_valid_data Capybara::Ambiguous: Ambiguous match, found 2 elements matching css ".select2-container"
I don't really understand enough about the issue that #37 fixes to know what the solution should be.
(cc @machisuji)
It currently has a dependency specifying rspec-core 2.99.0. It would be great to allow 3 to work now, as long as it doesn't have any side effects.
there hasn't been a new commit to this project in over a year, and has pull requests dating back to 2013.
I'm guessing this project is no longer maintained. If so, can you add a notice to the README.md?
Hello!
I'm running into an error when running this in rspec. I get this error:
Capybara::ElementNotFound:
Unable to find css ".select2-drop li" with text "Test"
When I run rspec, my browser starts up and the dropdown does actually open up and I see the "Test" item there, but then the dropdown just closes up without selecting the "Test" item. And then I get this "unable to find css" error.
Any ideas on what's going on?
Dear Everyone,
I have an error while I'm running rspec.
The error message : "undefined method `find' for nil:NilClass"
Could you guys help me?
Thanks & Regards,
Hi,
I'm trying to use capybara-select with minitest-rails-capybara
with no success.
Could you point me into the direction on how to configure capybara-select2 to be included into minitest?
TIA
Hi,
I am trying to select an option in my select2 that is inside an optgroup.
The error in capybara I get is:
Ambiguous match, found 2 elements matching css ".select2-dropdown li.select2-results__option" with text "Käpt’n Blaubär? (m)"
I called select2
like so:
select2 'Käpt’n Blaubär? (m)', css: '.select2-container'
My select2 with dummy data looks like this:
I suspect the ambiguity is caused by the fact that optgroups also have a 'select2-results__option' class:
<li aria-label="Boten" role="group" class="select2-results__option"><strong class="select2-results__group">Boten</strong>
<ul class="select2-results__options select2-results__options--nested">
<li aria-selected="false" role="treeitem" id="select2-name_of_my_select-result-hfih-4" class="select2-results__option select2-results__option--highlighted">Käpt’n Blaubär? (m)</li>
</ul>
</li>
So there are 2 elements that contain the text 'Käpt’n Blaubär? (m)', the group 'Boten' and the item itself.
A fix would be to add the role attribute into the selection for items [role=treeitem]
@goodwill It looks like people have found value in this. And a few people have chimed in that they would like to pick up the project.
Maybe it's time to add them to the repo 😄
I think we need some auto test for this to allow easier contrib validation as well as a starting point for people to understand how to use this (in case if this is not obvious enough...). My thought would be something like a very simple sinatra + rspec test. I have moved all gem files into a folder called gem so later when we use bundler to build a test project we should be able to simply use a path reference to include capybara-select2. A good reference on how to do that is here:
https://gist.github.com/juliocesar/639636
Anyone want to take on would be great as I am just too busy ATM.
I am using the select2 Multi-Value Select Boxes to select a music Genre.
Here is my test so far:
feature 'filtering searches' do
scenario 'a supporter filters their sort by genre' do
visit artists_path
select2_tag('Blues', from: 'Genre')
'Genre'.should have_content "blues"
end
end
I receive the following error:
Failure/Error: select2_tag('Blues', from: 'Genre')
NoMethodError:
undefined method `select2_tag' for # <RSpec::Core::ExampleGroup::Nested_6:0x007f823b3e52f0>
Here is my html.erb:
<div class="search_genre" color:"blue">Genre:</div>
<div class="select2-container select2-container-multi populate">
<select multiple="" name="e9" id="e9" style="width:300px" class="populate select2-offscreen" tabindex="-1" placeholder="Search or Select">
<optgroup label="Popular">
<option>Rock</option>
<option>Indie</option>
<option>Alternative</option>
<option>Acoustic</option>
</optgroup>
<optgroup label="All Genres">
<option>Acoustic</option>
<option>Alternative</option>
<option>Ambient</option>
<option>Blues</option>
</optgroup>
</select>
</div>
Hi!
I'm trying to check out you gem, but have some problem when run Spork to preload Rails environment. It says this:
Using RSpec Preloading Rails environment undefined method
configure' for RSpec:Module (NoMethodError)
/home/runfor/.rvm/gems/ruby-1.9.3-p327-fast/gems/capybara-select2-0.0.3/lib/capybara-select2.rb:20:in <top (required)>'
But rake spec works fine. Any suggestions why this error appear?
Hi,
I create a spec with this line :
select2("A first name A name", from: 'Artiste', search: true)
And I have this javascript :
$(this).select2(
placeholder: "Artiste"
minimumInputLength: 1
ajax:
url: '/artists.json'
data: (term) ->
q: term
results: (data) ->
results: data
It works on production but I have this error when I run my tests :
Failure/Error: select2("A first name A name", from: 'Artiste', search: true)
Capybara::Webkit::ClickFailed:
Failed to click element /html/body/div[@id='page']/div[@id='main-content']/div/div/form[@id='new_painting']/div[2]/div[1]/div/div[@id='s2id_painting_artist_id']/a at position 781,
The spec fail at this line : https://github.com/goodwill/capybara-select2/blob/master/gem/lib/capybara-select2.rb#L27
Is there something to do?
Thanks!
What's the integration with this with SitePrism? If any.
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.