Class: Capybarista::Element

Inherits:
Object
  • Object
show all
Includes:
Capybarista::Extensions::Element, Finders
Defined in:
lib/capybarista.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Capybarista::Extensions::Element

#blur, #filtered_attributes, #focus, #highlight, #inner_html, #label, #label!, #labels, #outer_html, #scoped, #top_left, #unique_xpath

Methods included from Capybarista::Extensions::Base

#all_fields

Methods included from Finders

#all, #find, #find_button, #find_by_id, #find_field, #find_link, #first

Constructor Details

#initialize(element, session) ⇒ Element

Returns a new instance of Element.



80
81
82
83
# File 'lib/capybarista.rb', line 80

def initialize(element, session)
  @basis   = element
  @session = session
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



104
105
106
# File 'lib/capybarista.rb', line 104

def method_missing(name, *args, &block)
  @basis.public_send(name, *args, &block)
end

Instance Attribute Details

#basisObject (readonly)

Returns the value of attribute basis.



78
79
80
# File 'lib/capybarista.rb', line 78

def basis
  @basis
end

#sessionObject (readonly)

Returns the value of attribute session.



78
79
80
# File 'lib/capybarista.rb', line 78

def session
  @session
end

Class Method Details

.for(input, session = nil) ⇒ Object



85
86
87
88
89
90
91
92
# File 'lib/capybarista.rb', line 85

def self.for(input, session = nil)
  if input.is_a? Capybarista::Element
    return input
  else
    session ||= Capybarista::Session.new(input.session)
    return Capybarista::Element.new input
  end
end

.unwrap(input) ⇒ Object



95
96
97
98
99
100
# File 'lib/capybarista.rb', line 95

def self.unwrap(input)
  while input.is_a? Capybarista::Element
    input = input.basis
  end
  input
end