Class: Capybara::Select2::Element
- Inherits:
-
Object
- Object
- Capybara::Select2::Element
- Defined in:
- lib/capybara_select2.rb
Instance Attribute Summary collapse
-
#container ⇒ Object
Returns the value of attribute container.
-
#multiselect ⇒ Object
Returns the value of attribute multiselect.
-
#page ⇒ Object
Returns the value of attribute page.
-
#search_enabled ⇒ Object
Returns the value of attribute search_enabled.
Instance Method Summary collapse
- #drop_container_class ⇒ Object
-
#initialize(page_context, options = {}) ⇒ Element
constructor
A new instance of Element.
- #initiate!(value) ⇒ Object
- #select_match! ⇒ Object
Constructor Details
#initialize(page_context, options = {}) ⇒ Element
Returns a new instance of Element.
8 9 10 11 12 13 |
# File 'lib/capybara_select2.rb', line 8 def initialize(page_context, = {}) self.page = page_context self.search_enabled = !![:search] self.multiselect = !![:multiple] find_container(.slice(:from, :xpath)) end |
Instance Attribute Details
#container ⇒ Object
Returns the value of attribute container.
6 7 8 |
# File 'lib/capybara_select2.rb', line 6 def container @container end |
#multiselect ⇒ Object
Returns the value of attribute multiselect.
6 7 8 |
# File 'lib/capybara_select2.rb', line 6 def multiselect @multiselect end |
#page ⇒ Object
Returns the value of attribute page.
6 7 8 |
# File 'lib/capybara_select2.rb', line 6 def page @page end |
#search_enabled ⇒ Object
Returns the value of attribute search_enabled.
6 7 8 |
# File 'lib/capybara_select2.rb', line 6 def search_enabled @search_enabled end |
Instance Method Details
#drop_container_class ⇒ Object
15 16 17 |
# File 'lib/capybara_select2.rb', line 15 def drop_container_class if search_enabled then '.select2-results' else '.select2-drop' end end |
#initiate!(value) ⇒ Object
23 24 25 26 |
# File 'lib/capybara_select2.rb', line 23 def initiate!(value) focus! search!(value) if search_enabled end |
#select_match! ⇒ Object
19 20 21 |
# File 'lib/capybara_select2.rb', line 19 def select_match! page.find(:css, drop_container_class).find(:css, ".select2-match").click end |