GithubHelp home page GithubHelp logo

goodwill / capybara-select2 Goto Github PK

View Code? Open in Web Editor NEW
80.0 80.0 111.0 303 KB

Helper for capybara to be able to trigger select on select2 javascript (needed for js enabled test only)

License: MIT License

Ruby 100.00%

capybara-select2's People

Contributors

adamico avatar divineforest avatar exaspark avatar flyerhzm avatar gmassanek avatar goodwill avatar lstuker avatar machisuji avatar martijn avatar pedrocss avatar samsm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

capybara-select2's Issues

Error

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

Time for new RubyGems release?

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?

Having issues with tests timing out

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:

<Capybara::Element tag="div">

Any ideas?

BR

Capybara::Webkit::ClickFailed

Dear Goodwill,

Currently, I got an new error "Capybara::Webkit::ClickFailed".
Do you have any idea about this error?

Thanks & Regards,
Bunhok

Capybara::Poltergeist::MouseEventFailed

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 %>

Find exact

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

Capybara::Select2#select2 has unexpected interface for :css, :xpath

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...

Release the 1.0.0 gem

The current rubygems gem is versioned at 0.0.8 but master has lots of fixes and is versioned at 1.0.0.

`Ambiguous match` when there are multiple select2 elements

#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)

Project no longer maintained?

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?

unable to find css

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?

I got an error using select2 method.

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,

using with minitest

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

Incompatible with optgroups?

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:

image

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]

Find a new maintainer

@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 😄

Create a sinatra based rspec + capybara test

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.

undefined method select2_tag

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>

undefined method `configure' for RSpec:Module

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?

Failed to click element

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.