lib/watir/image.rb in watir-3.0.0.rc2 vs lib/watir/image.rb in watir-3.0.0.rc3

- old
+ new

@@ -4,19 +4,14 @@ # Normally a user would not need to create this object as it is returned by the Watir::Container#image method # # many of the methods available to this object are inherited from the Element class # class Image < Element - TAG = "IMG" + attr_ole :alt + attr_ole :src + attr_ole :file_created_date, :fileCreatedDate - def initialize(container, how, what) - set_container container - @how = how - @what = what - super nil - end - # this method produces the properties for an image as an array def image_string_creator n = [] n << "src:".ljust(TO_S_SIZE) + self.src.to_s n << "file date:".ljust(TO_S_SIZE) + self.fileCreatedDate.to_s @@ -34,43 +29,35 @@ r = string_creator r += image_string_creator return r.join("\n") end - # this method returns the file created date of the image - def file_created_date - assert_exists - return @o.invoke("fileCreatedDate") - end - # this method returns the filesize of the image, as an int def file_size assert_exists - return @o.invoke("fileSize").to_i + @o.invoke("fileSize").to_i end # returns the width in pixels of the image, as an int def width assert_exists - return @o.invoke("width").to_i + @o.invoke("width").to_i end # returns the height in pixels of the image, as an int def height assert_exists - return @o.invoke("height").to_i + @o.invoke("height").to_i end # This method attempts to find out if the image was actually loaded by the web browser. # If the image was not loaded, the browser is unable to determine some of the properties. # We look for these missing properties to see if the image is really there or not. # If the Disk cache is full (tools menu -> Internet options -> Temporary Internet Files), it may produce incorrect responses. def loaded? - locate - raise UnknownObjectException, "Unable to locate image using #{@how} and #{@what}" if @o == nil - return false if @o.fileCreatedDate == "" and @o.fileSize.to_i == -1 - return true + assert_exists + !file_created_date.empty? && file_size != -1 end # this method highlights the image (in fact it adds or removes a border around the image) # * set_or_clear - symbol - :set to set the border, :clear to remove it def highlight(set_or_clear) @@ -117,12 +104,8 @@ "window.button(:value => '&Save').click" IO.popen("ruby -e \"#{command}\"") end private :fill_save_image_dialog - Watir::Container.module_eval do - alias_method :img, :image - alias_method :imgs, :images - end end end