Class: Lebowski::Foundation::DOMElement
- Inherits:
-
Object
- Object
- Lebowski::Foundation::DOMElement
- Includes:
- Mixins::UserActions
- Defined in:
- lib/lebowski/foundation/dom_element.rb
Overview
Represents a DOM element. Primarily used by the CoreQuery object. Use this object to acquire details about a given element.
Constant Summary
Constant Summary
Constants included from Mixins::StallSupport
Mixins::StallSupport::DEFAULT_KEY_STALLS, Mixins::StallSupport::DEFAULT_STALL
Instance Attribute Summary (collapse)
-
- (Object) handle
readonly
Returns the value of attribute handle.
-
- (Object) index
readonly
Returns the value of attribute index.
Instance Method Summary (collapse)
- - (Object) action_locator_args
- - (Object) action_target
-
- (Object) attribute(val)
Used to get the value of specific attribute belonging to the element.
-
- (Object) classes
Returns the classes of the element as a string.
-
- (Boolean) has_class?(klass)
Checks if this DOM element has a given CSS class.
-
- (Boolean) has_classes?(klasses)
Checks if this DOM element has a set of given CSS classes.
- - (Object) height
-
- (Object) html
Returns the raw HTML of this element as a string.
-
- (DOMElement) initialize(handle, index, driver)
constructor
Create an instance.
-
- (Object) method_missing(sym, *args, &block)
If the method can not be found then assume we are trying to get the value of an attribute on the element.
- - (Object) position
-
- (Object) tag
Returns the HTML tag of this element (e.g. IMG, A, DIV).
-
- (Object) text
Returns the text of this element.
- - (Object) width
Methods included from Mixins::UserActions
#basic_click, #click, #click_at, #double_click, #double_click_at, #drag, #drag_after, #drag_before, #drag_on_to, #drag_to, #drag_to_end_of, #drag_to_start_of, #focus, #key_down, #key_up, #mouse_down, #mouse_down_at, #mouse_move, #mouse_move_at, #mouse_up, #mouse_up_at, #mouse_wheel_delta_x, #mouse_wheel_delta_y, #right_click, #right_click_at, #right_mouse_down, #right_mouse_down_at, #right_mouse_up, #right_mouse_up_at, #type, #type_key
Methods included from Mixins::StallSupport
adjust_all_stalls, adjust_default_key_stall, adjust_default_stall, reset, #stall
Methods included from Mixins::KeyCheck
Methods included from Mixins::PositionedElement
#position_relative_to, #scroll_to_visible
Constructor Details
- (DOMElement) initialize(handle, index, driver)
Create an instance.
26 27 28 29 30 |
# File 'lib/lebowski/foundation/dom_element.rb', line 26 def initialize(handle, index, driver) @handle = handle @index = index @driver = driver end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(sym, *args, &block)
If the method can not be found then assume we are trying to get the value of an attribute on the element.
121 122 123 124 |
# File 'lib/lebowski/foundation/dom_element.rb', line 121 def method_missing(sym, *args, &block) return attribute(sym.to_s) if not sym.to_s =~ /\?$/ super end |
Instance Attribute Details
- (Object) handle (readonly)
Returns the value of attribute handle
16 17 18 |
# File 'lib/lebowski/foundation/dom_element.rb', line 16 def handle @handle end |
- (Object) index (readonly)
Returns the value of attribute index
16 17 18 |
# File 'lib/lebowski/foundation/dom_element.rb', line 16 def index @index end |
Instance Method Details
- (Object) action_locator_args
32 33 34 |
# File 'lib/lebowski/foundation/dom_element.rb', line 32 def action_locator_args() return [@handle, @index] end |
- (Object) action_target
36 37 38 |
# File 'lib/lebowski/foundation/dom_element.rb', line 36 def action_target() return :core_query_element end |
- (Object) attribute(val)
Used to get the value of specific attribute belonging to the element
98 99 100 |
# File 'lib/lebowski/foundation/dom_element.rb', line 98 def attribute(val) return @driver.get_sc_core_query_element_attribute(@handle, @index, val) end |
- (Object) classes
Returns the classes of the element as a string
43 44 45 |
# File 'lib/lebowski/foundation/dom_element.rb', line 43 def classes() return @driver.get_sc_core_query_element_classes(@handle, @index) end |
- (Boolean) has_class?(klass)
Checks if this DOM element has a given CSS class
52 53 54 |
# File 'lib/lebowski/foundation/dom_element.rb', line 52 def has_class?(klass) return has_classes? [klass] end |
- (Boolean) has_classes?(klasses)
Checks if this DOM element has a set of given CSS classes
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/lebowski/foundation/dom_element.rb', line 61 def has_classes?(klasses) klasses1 = klasses.kind_of?(Array) ? klasses : klasses.split klasses2 = classes.split for k in klasses1 do if not klasses2.find_index(k) return false end end return true end |
- (Object) height
113 114 115 |
# File 'lib/lebowski/foundation/dom_element.rb', line 113 def height() return @driver.get_sc_element_height(action_target, *action_locator_args) end |
- (Object) html
Returns the raw HTML of this element as a string
75 76 77 |
# File 'lib/lebowski/foundation/dom_element.rb', line 75 def html() return @driver.get_sc_core_query_element_html(@handle, @index) end |
- (Object) position
103 104 105 |
# File 'lib/lebowski/foundation/dom_element.rb', line 103 def position() return @driver.get_sc_element_window_position(action_target, *action_locator_args) end |
- (Object) tag
Returns the HTML tag of this element (e.g. IMG, A, DIV)
89 90 91 |
# File 'lib/lebowski/foundation/dom_element.rb', line 89 def tag() return @driver.get_sc_core_query_element_tag(@handle, @index) end |
- (Object) text
Returns the text of this element
82 83 84 |
# File 'lib/lebowski/foundation/dom_element.rb', line 82 def text() return @driver.get_sc_core_query_element_text(@handle, @index) end |
- (Object) width
108 109 110 |
# File 'lib/lebowski/foundation/dom_element.rb', line 108 def width() return @driver.get_sc_element_width(action_target, *action_locator_args) end |