Class: FireWatir::NonControlElement
- Defined in:
- lib/firewatir/elements/non_control_element.rb
Overview
Base class containing items that are common between the span, div, label, p and pre classes.
Direct Known Subclasses
Area, Body, Dd, Div, Dl, Dt, Em, H1, H2, H3, H4, H5, H6, Label, Li, Map, P, Pre, Span, Strong, Ul
Constant Summary
Constants inherited from Element
Element::FIRST_ORDERED_NODE_TYPE, Element::NUMBER_TYPE, Element::ORDERED_NODE_ITERATOR_TYPE, Element::TO_S_SIZE
Constants included from Container
Container::DEFAULT_HIGHLIGHT_COLOR, Container::MACHINE_IP
Instance Attribute Summary collapse
-
#element_name ⇒ Object
Returns the value of attribute element_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(container, how, what) ⇒ NonControlElement
constructor
-
how - Attribute to identify the element.
-
-
#locate ⇒ Object
Description: Locate the element on the page.
-
#to_s(attributes = nil) ⇒ Object
Returns a string of properties of the object.
Methods inherited from Element
#assert_enabled, #assert_exists, #attribute_value, #click, #contains_text, #disabled, #document_var, #element_by_xpath, #element_type, #elements_by_xpath, #enabled?, #exists?, #fire_event, #inspect, #method_missing, #text, #visible?, #wait
Methods included from Container
#button, #cell, #checkbox, #dd, #dl, #dt, #file_field, #form, #frame, #hidden, #image, #link, #radio, #row, #select_list, #show_all_objects, #table, #text_field
Methods included from JsshSocket
#js_eval, #js_eval_method, #jssh_socket, #read_socket
Constructor Details
#initialize(container, how, what) ⇒ NonControlElement
-
how - Attribute to identify the element.
-
what - Value of that attribute.
-
33 34 35 36 37 38 39 |
# File 'lib/firewatir/elements/non_control_element.rb', line 33 def initialize(container, how, what) #@element = Element.new(nil) @how = how @what = what @container = container @o = nil end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class FireWatir::Element
Instance Attribute Details
#element_name ⇒ Object
Returns the value of attribute element_name.
13 14 15 |
# File 'lib/firewatir/elements/non_control_element.rb', line 13 def element_name @element_name end |
Class Method Details
.inherited(subclass) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/firewatir/elements/non_control_element.rb', line 5 def self.inherited subclass class_name = subclass.to_s.demodulize method_name = class_name.underscore FireWatir::Container.module_eval "def #{method_name}(how, what=nil) locate if respond_to?(:locate) return #{class_name}.new(self, how, what); end" end |
Instance Method Details
#locate ⇒ Object
Description:
Locate the element on the page. Element can be a span, div, label, p or pre HTML tag.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/firewatir/elements/non_control_element.rb', line 19 def locate case @how when :jssh_name @element_name = @what when :xpath @element_name = element_by_xpath(@container, @what) else @element_name = locate_tagged_element(self.class::TAG, @how, @what) end @o = self end |
#to_s(attributes = nil) ⇒ Object
Returns a string of properties of the object.
42 43 44 45 46 47 48 49 50 |
# File 'lib/firewatir/elements/non_control_element.rb', line 42 def to_s(attributes = nil) assert_exists hash_properties = {"text"=>"innerHTML"} hash_properties.update(attributes) if attributes != nil r = super(hash_properties) #r = string_creator #r += span_div_string_creator return r.join("\n") end |