lib/watir/image.rb in watir-2.0.4 vs lib/watir/image.rb in watir-3.0.0.rc1
- old
+ new
@@ -40,26 +40,26 @@
def file_created_date
assert_exists
return @o.invoke("fileCreatedDate")
end
- # this method returns the filesize of the image
+ # this method returns the filesize of the image, as an int
def file_size
assert_exists
- return @o.invoke("fileSize").to_s
+ return @o.invoke("fileSize").to_i
end
- # returns the width in pixels of the image, as a string
+ # returns the width in pixels of the image, as an int
def width
assert_exists
- return @o.invoke("width").to_s
+ return @o.invoke("width").to_i
end
- # returns the height in pixels of the image, as a string
+ # returns the height in pixels of the image, as an int
def height
assert_exists
- return @o.invoke("height").to_s
+ return @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.
@@ -101,25 +101,22 @@
# for overwrite.
# path - directory path and file name of where image should be saved
def save(path)
@container.goto(src)
begin
- thrd = fill_save_image_dialog(path)
+ fill_save_image_dialog(path)
@container.document.execCommand("SaveAs")
- thrd.join(5)
ensure
@container.back
end
end
def fill_save_image_dialog(path)
- command = "require 'rautomation';" <<
+ command = "require 'rubygems';require 'rautomation';" <<
"window=::RAutomation::Window.new(:title => 'Save Picture');" <<
- "window.text_field(:class => 'Edit', :index => 0).set('#{path}');" <<
+ "window.text_field(:class => 'Edit', :index => 0).set('#{path.gsub(File::SEPARATOR, File::ALT_SEPARATOR)}');" <<
"window.button(:value => '&Save').click"
- Thread.new do
- system("ruby -e \"#{command}\"")
- end
+ IO.popen("ruby -e \"#{command}\"")
end
private :fill_save_image_dialog
Watir::Container.module_eval do
alias_method :img, :image