Class: FireWatir::Image
- Defined in:
- lib/firewatir/elements/image.rb
Overview
Description:
Class for Image element.
Constant Summary collapse
- TAG =
'IMG'
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.
Instance Method Summary collapse
-
#height ⇒ Object
Description: Gets the height of the image in pixels, as a string.
-
#initialize(container, how, what) ⇒ Image
constructor
Description: Initializes the instance of image object.
-
#locate ⇒ Object
Description: Locate the image element on the page.
-
#to_s ⇒ Object
returns a string representation of the object.
-
#width ⇒ Object
Description: Gets the width of the image in pixels, as a string.
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) ⇒ Image
Description:
Initializes the instance of image object.
Input:
- how - Attribute to identify the image element.
- what - Value of that attribute.
17 18 19 20 21 |
# File 'lib/firewatir/elements/image.rb', line 17 def initialize(container, how, what) @how = how @what = what @container = container 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.
7 8 9 |
# File 'lib/firewatir/elements/image.rb', line 7 def element_name @element_name end |
Instance Method Details
#height ⇒ Object
Description:
Gets the height of the image in pixels, as a string.
Output:
Height of image (in pixels).
93 94 95 96 |
# File 'lib/firewatir/elements/image.rb', line 93 def height assert_exists return @o.invoke("height").to_s end |
#locate ⇒ Object
Description:
Locate the image element on the page.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/firewatir/elements/image.rb', line 26 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('IMG', @how, @what) end @o = self end |
#to_s ⇒ Object
returns a string representation of the object
55 56 57 58 |
# File 'lib/firewatir/elements/image.rb', line 55 def to_s assert_exists super({"src" => "src","width" => "width","height" => "height","alt" => "alt"}) end |
#width ⇒ Object
Description:
Gets the width of the image in pixels, as a string.
Output:
Width of image (in pixels).
81 82 83 84 |
# File 'lib/firewatir/elements/image.rb', line 81 def width assert_exists return @o.invoke("width").to_s end |