Class: Capypage::Element
- Inherits:
-
Object
- Object
- Capypage::Element
- Includes:
- ElementProxy
- Defined in:
- lib/capypage/element.rb
Instance Attribute Summary collapse
-
#base_element ⇒ Object
readonly
Returns the value of attribute base_element.
-
#finder_options ⇒ Object
readonly
Returns the value of attribute finder_options.
-
#select_using ⇒ Object
readonly
Returns the value of attribute select_using.
-
#selector ⇒ Object
readonly
Returns the value of attribute selector.
Instance Method Summary collapse
- #element(name, selector, options = {}) ⇒ Object
- #elements(name, selector, options = {}, &block) ⇒ Object
-
#initialize(selector, options = {}, &block) ⇒ Element
constructor
A new instance of Element.
- #not_present? ⇒ Boolean
- #present? ⇒ Boolean
- #visible?(options = {}) ⇒ Boolean
Constructor Details
#initialize(selector, options = {}, &block) ⇒ Element
Returns a new instance of Element.
10 11 12 13 14 15 16 17 |
# File 'lib/capypage/element.rb', line 10 def initialize(selector, = {}, &block) @finder_options = .reverse_merge :match => :first @selector = selector @base_element = [:base_element] @select_using = .delete(:select_using) || Capybara.default_selector block.call(self) if block.present? end |
Instance Attribute Details
#base_element ⇒ Object (readonly)
Returns the value of attribute base_element.
8 9 10 |
# File 'lib/capypage/element.rb', line 8 def base_element @base_element end |
#finder_options ⇒ Object (readonly)
Returns the value of attribute finder_options.
8 9 10 |
# File 'lib/capypage/element.rb', line 8 def @finder_options end |
#select_using ⇒ Object (readonly)
Returns the value of attribute select_using.
8 9 10 |
# File 'lib/capypage/element.rb', line 8 def select_using @select_using end |
#selector ⇒ Object (readonly)
Returns the value of attribute selector.
8 9 10 |
# File 'lib/capypage/element.rb', line 8 def selector @selector end |
Instance Method Details
#element(name, selector, options = {}) ⇒ Object
19 20 21 22 |
# File 'lib/capypage/element.rb', line 19 def element(name, selector, = {}) base = self define_singleton_method(name) { Element.new(selector, .merge(:base_element => base)) } end |
#elements(name, selector, options = {}, &block) ⇒ Object
24 25 26 27 |
# File 'lib/capypage/element.rb', line 24 def elements(name, selector, = {}, &block) base = self define_singleton_method(name) { Elements.new(selector, .merge(:base_element => base), &block) } end |
#not_present? ⇒ Boolean
33 34 35 |
# File 'lib/capypage/element.rb', line 33 def not_present? base_element.has_no_selector? selector, end |
#present? ⇒ Boolean
29 30 31 |
# File 'lib/capypage/element.rb', line 29 def present? base_element.has_selector? selector, end |
#visible?(options = {}) ⇒ Boolean
37 38 39 40 41 |
# File 'lib/capypage/element.rb', line 37 def visible?( = {}) ().visible? rescue Capybara::ElementNotFound false end |