Class: Celerity::Image
- Includes:
- ClickableElement
- Defined in:
- lib/celerity/elements/image.rb,
lib/celerity/watir_compatibility.rb
Constant Summary collapse
- TAGS =
[ Identifier.new('img') ]
- ATTRIBUTES =
BASE_ATTRIBUTES | [:src, :alt, :longdesc, :name, :height, :width, :usemap, :ismap, :align, :border, :hspace, :vspace]
- DEFAULT_HOW =
:src
Constants inherited from Element
Element::BASE_ATTRIBUTES, Element::CELLHALIGN_ATTRIBUTES, Element::CELLVALIGN_ATTRIBUTES, Element::HTML_401_TRANSITIONAL, Element::TO_S_SIZE
Instance Attribute Summary
Attributes inherited from Element
Attributes included from Container
Instance Method Summary collapse
-
#file_created_date ⇒ Object
(also: #fileCreatedDate)
returns the file created date of the image.
-
#file_size ⇒ Object
(also: #fileSize)
returns the file size of the image in bytes.
-
#height ⇒ Object
returns the height in pixels of the image, as a string.
-
#loaded? ⇒ Boolean
(also: #hasLoaded?, #has_loaded?)
returns true if the image is loaded.
-
#save(filename) ⇒ Object
Saves the image to the given file.
-
#width ⇒ Object
returns the width in pixels of the image, as a string.
Methods included from ClickableElement
#click, #click_and_attach, #double_click, #download, #right_click
Methods inherited from Element
#assert_exists, #attribute_string, #attribute_value, #exists?, #fire_event, #focus, #initialize, #javascript_object, #locate, #method_missing, #methods, #object, #parent, #respond_to?, #text, #to_s, #to_xml, #visible?, #xpath
Methods included from Container
#area, #areas, #button, #buttons, #cell, #cells, #check_box, #checkboxes, #container=, #contains_text, #dd, #dds, #div, #divs, #dl, #dls, #dt, #dts, #em, #ems, #file_field, #file_fields, #form, #forms, #frame, #frames, #h1, #h1s, #h2, #h2s, #h3, #h3s, #h4, #h4s, #h5, #h5s, #h6, #h6s, #hidden, #hiddens, #image, #images, #inspect, #label, #labels, #li, #link, #links, #lis, #map, #maps, #meta, #metas, #ol, #ols, #option, #p, #pre, #pres, #ps, #radio, #radios, #row, #rows, #select_list, #select_lists, #span, #spans, #strong, #strongs, #table, #tables, #tbodies, #tbody, #text_field, #text_fields, #tfoot, #tfoots, #th, #thead, #theads, #ths, #ul, #uls
Methods included from ShortInspect
Constructor Details
This class inherits a constructor from Celerity::Element
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Celerity::Element
Instance Method Details
#file_created_date ⇒ Object Also known as: fileCreatedDate
returns the file created date of the image
15 16 17 18 19 |
# File 'lib/celerity/elements/image.rb', line 15 def file_created_date assert_exists web_response = @object.getWebResponse(true) Time.parse(web_response.getResponseHeaderValue("Last-Modified").to_s) end |
#file_size ⇒ Object Also known as: fileSize
returns the file size of the image in bytes
25 26 27 28 29 |
# File 'lib/celerity/elements/image.rb', line 25 def file_size assert_exists web_response = @object.getWebResponse(true) web_response.getContentAsBytes.length end |
#height ⇒ Object
returns the height in pixels of the image, as a string
44 45 46 47 |
# File 'lib/celerity/elements/image.rb', line 44 def height assert_exists @object.getHeight end |
#loaded? ⇒ Boolean Also known as: hasLoaded?, has_loaded?
returns true if the image is loaded
53 54 55 56 57 58 59 60 61 |
# File 'lib/celerity/elements/image.rb', line 53 def loaded? assert_exists begin @object.getImageReader true rescue false end end |
#save(filename) ⇒ Object
Saves the image to the given file
67 68 69 70 71 72 73 |
# File 'lib/celerity/elements/image.rb', line 67 def save(filename) assert_exists image_reader = @object.getImageReader file = java.io.File.new(filename) buffered_image = image_reader.read(0); javax.imageio.ImageIO.write(buffered_image, image_reader.getFormatName(), file); end |
#width ⇒ Object
returns the width in pixels of the image, as a string
35 36 37 38 |
# File 'lib/celerity/elements/image.rb', line 35 def width assert_exists @object.getWidth end |