Class: Napybara::Element
- Inherits:
-
Object
- Object
- Napybara::Element
- Defined in:
- lib/napybara/element.rb
Instance Attribute Summary collapse
-
#node ⇒ Object
(also: #get)
readonly
Returns the value of attribute node.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#selector_string ⇒ Object
readonly
Returns the value of attribute selector_string.
Instance Method Summary collapse
- #finder(child_element_name, child_element_selector, *optional_args, &block) ⇒ Object
-
#initialize(node, parent = nil, selector_string = nil, &block) ⇒ Element
constructor
A new instance of Element.
- #inspect ⇒ Object
- #root ⇒ Object
- #selector ⇒ Object
Constructor Details
#initialize(node, parent = nil, selector_string = nil, &block) ⇒ Element
Returns a new instance of Element.
9 10 11 12 13 14 15 |
# File 'lib/napybara/element.rb', line 9 def initialize(node, parent = nil, selector_string = nil, &block) @node = node @parent = parent @selector_string = selector_string block.call(self) if block_given? end |
Instance Attribute Details
#node ⇒ Object (readonly) Also known as: get
Returns the value of attribute node.
5 6 7 |
# File 'lib/napybara/element.rb', line 5 def node @node end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
5 6 7 |
# File 'lib/napybara/element.rb', line 5 def parent @parent end |
#selector_string ⇒ Object (readonly)
Returns the value of attribute selector_string.
5 6 7 |
# File 'lib/napybara/element.rb', line 5 def selector_string @selector_string end |
Instance Method Details
#finder(child_element_name, child_element_selector, *optional_args, &block) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/napybara/element.rb', line 17 def finder(child_element_name, child_element_selector, *optional_args, &block) appender = FinderMethodsAppender.new( self, child_element_name, child_element_selector, optional_args, block) appender.execute end |
#inspect ⇒ Object
24 25 26 |
# File 'lib/napybara/element.rb', line 24 def inspect %(#<Napybara::Element selector="#{selector}">) end |
#root ⇒ Object
28 29 30 |
# File 'lib/napybara/element.rb', line 28 def root parent ? parent.parent : self end |
#selector ⇒ Object
32 33 34 35 |
# File 'lib/napybara/element.rb', line 32 def selector parent_selector = parent.try(:selector) parent_selector ? "#{parent_selector} #{selector_string}" : selector_string end |