Code Monkey home page Code Monkey logo

capybara_select2's People

Contributors

dorianmariecom avatar frankolson avatar garymh avatar hirurg103 avatar kreintjes avatar lucas-eduardo-easycredito avatar lucascaton avatar r4do avatar therealneil 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

Watchers

 avatar  avatar  avatar

capybara_select2's Issues

Cannot use `select2` within modal

This code fails:

within('#someModal') do
  select2 'some_tag', from 'Tags', tag: true
end

is failing with:

Unable to find visible css ".select2-container-active .select2-result,.select2-drop-active .select2-result,.select2-results .select2-results
__option" with text "some_tag" within #<Capybara::Node::Element tag="div" path="/html/body/div[@id='modalBlock']/div[@id='someModal']"

This is because the selected option is added to a container outside the modal

Maybe https://github.com/Hirurg103/capybara_select2/blob/master/lib/capybara_select2/helpers.rb#L42 should search from the body?

Thank you for reviving this gem!

Add specific select2 helpers

I am not sure if we need the test helpers below so I am asking for the community help.

Please add ๐Ÿ‘ if you need the helpers or ๐Ÿ‘Ž if you think they are not necessary

# open select2 widget
select2_open css: '.select2'
select2_open label: 'Todo'

# close select2 widget
select2_close css: '.select2'
select2_close label: 'Todo'

# type into the search field within an opened select2 widget
select2_search 'Minsk'

# select an option from an opened select box
select2_select_option 'Buy Milk'

If you think that only some of the helpers above might be useful please add your opinion in the comments below

Does Not Seems to Have Support for `within`

Let's say we have a form which requires users to fill fields for two comments. Each comment has the same set of fields, including a Type field which is a select2 dropdown. Ideally, wrapping the select2 call around within should do the trick but that's not happening.

The following snippet

within '#comment_1` do
  select2 'Note', from: 'Type'
end

results in the following error

Capybara::Ambiguous:
       Ambiguous match, found 2 elements matching visible css ".select2-results .select2-results__option[aria-selected='false']" within #<Capybara::Node::Element tag="body" path="/HTML/BODY[1]">

because there is another Type dropdown within #comment_2.

Seems to me, the problem is that the method referenced below does not takes within into consideration.

def self.find_select2_container(options, page)

Also, seems to be related to #1.

Please clarify what selector is being used in the documentation

I spent about an hour trying to figure out what selector (#my_selector) was being used. I tried the id of the select tag in question, then looked for options to pass an explicit id to select2, then spend time reading through your source code.

It was only after reading your own specs, and your HTML files that I discovered how to use your code. I appreciate your work, and that you've made it available, but it is extremely frustrating to have to do this.

It was not clear until then that #my_selector is an unrelated unique parent of the select2 element being targeted...

undefined method `configure' for RSpec:Module

Hi @Hirurg103

I upgraded to version 0.2.1 but when I run the specs I get:

/usr/local/rvm/gems/ruby-2.5.1@ideas4all-brasaas/gems/bundler-1.16.3/lib/bundler/runtime.rb:84:in `rescue in block (2 levels) in require': There wa
s an error while trying to load the gem 'capybara-select-2'.                                                                                      
Gem Load Error is: undefined method `configure' for RSpec:Module                                                                                  
Backtrace for gem load error is:                                                                                                                  
/usr/local/rvm/gems/ruby-2.5.1@ideas4all-brasaas/gems/capybara-select-2-0.2.1/lib/capybara_select2.rb:10:in `<top (required)>'                    
/usr/local/rvm/gems/ruby-2.5.1@ideas4all-brasaas/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:274:in `require'                     
/usr/local/rvm/gems/ruby-2.5.1@ideas4all-brasaas/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:274:in `block in require'            
/usr/local/rvm/gems/ruby-2.5.1@ideas4all-brasaas/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:240:in `load_dependency'             
/usr/local/rvm/gems/ruby-2.5.1@ideas4all-brasaas/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:274:in `require'                     
/usr/local/rvm/gems/ruby-2.5.1@ideas4all-brasaas/gems/capybara-select-2-0.2.1/lib/capybara-select-2.rb:1:in `<top (required)>'     
....

Maybe some require is needed to use Rspec.configure?

Select2 with tag is using a textarea for the search input rather than an input

I'm using a select2 element with the tag option. When I use select2 'something', from: 'Something', tag: true I get the error:

Capybara::ElementNotFound:
       Unable to find css ".select2-container--open input.select2-search__field" within #<Capybara::Node::Element tag="body" path="/HTML/BODY[1]">

When I look at the code on the page, the .select2-search__field element is a textarea rather than an input. I think that's reflected in the select2 code here

I think additional search input selectors are needed. If I add this before select2 call:

CapybaraSelect2::Selectors::SearchInputSelectors = {'4' => ".select2-container--open textarea.select2-search__field" }

The test runs without error.

"Capybara::ElementNotFound"

Hi there,

Just installed capybara-select-2. I'm generating a select2 from a grouped select:

= f.select(:for_programme_ids, Programme.grouped_options_for_select, {}, multiple: true, class: 'form-control select select2')

I'm trying to select an option:

select2(project1.programmes[0].name, from: 'Programmes', search: true)

and getting this error:

Capybara::ElementNotFound: Unable to find css ".select2-results .select2-results__option[role='treeitem']" within #<Capybara::Node::Element tag="body" path="/HTML/BODY[1]">

I'm using CapybaraSelect2 0.4.2, Select2 4.0.12, Capybara 3.29.0, rspec-core 3.8.2, rspec-rails 3.8.3, Ruby 2.5.3 and Rails 5.2.3.

When I inspect the HTML, the options have role="option", not role="treeitem".

Any idea what the issue is or what to do about it?

Thanks :)

Thank You!!!

I don't really have an issue, but I just wanted to say thanks for making this and keeping it up to date. I recently updated select-2 and realized my tests started failing. I was delighted to see you had already addressed it in the new version of the gem.

Feel free to close this issue. I just wan't sure where to say thanks!

Can we get a new release?

Thanks for this nice library. :)

Can I ask you to cut a new release - I am hoping that maybe changes on master fix some random crashes we're experiencing...

Selecting more than one select2 issue

Hi,

When I run a test that selects options from several select2 dropdowns I get the following error:

Selenium::WebDriver::Error::ElementClickInterceptedError: element click intercepted: Element <a href="javascript:void(0)" class="select2-choice select2-default" tabindex="-1">...</a> is not clickable at point (1119, 356). Other element would receive the click: <span title="...">Wed</span> (Session info: headless chrome=78.0.3904.70)

Select2 v3.5

Is there a way round this?

If I just select one dropdown it works fine, but if I run 2 it throws up the error.

select2 'cart', from: 'Status'
select2 'paid', from: 'Payment State'
click_on 'Filter Results'

Support for expectations

What about helpers for asserting select2 content?

Something like:

expect(select2(from: 'Things to do')).to have_content(['one', 'two', 'three'])

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.