watir-extensions-element-screenshot
watir-extensions-element-screenshot copied to clipboard
Original image height is too small! (ChunkyPNG::OutOfBounds)
I am getting the below error when trying to capture screenshots of elements
C:/Ruby200/lib/ruby/gems/2.0.0/gems/chunky_png-1.3.1/lib/chunky_png/canvas/opera
tions.rb:175:in crop!': Original image height is too small! (ChunkyPNG::OutOfBo unds) from C:/Ruby200/lib/ruby/gems/2.0.0/gems/watir-extensions-element-screen shot-0.0.2/lib/watir/extensions/element/screenshot.rb:11:inscreenshot'
from angular_test.rb:15:in `
Hi anilreddy, The ChunkyPNG code simply does a bounds check on the element. Could you let me know what browser you are using and verify that the element has a height and width(<element_obj>.wd.size.height and <element_obj>.wd.size.width).
I'm not sure what the appropriate behavior should be. Potentially I could return the entire screenshot. At this point, I am thinking of simply throwing a better error.
Thoughts?
@ansoni i am using chrome browser and the element has height of 250 * width 350
I was getting this error when I tried to capture a screenshot of an element while my browser window was too small to fully fit the element. Resizing/maximizing the browser window worked for me. Are you sure the element is fully visible in your browser window?
Just giving another heads up here but I was getting this exception while taking a screenshot in IE.
Adding browser.window.size to watir/extensions/element/screenshot.rb before the browser.screenshot.save(file) line solved my problem (no idea why though..).
This might save someone a headache.
I'm also getting the same error over and over again, even when I resize the browser window..
For my testing purposes, I use:
b = Watir::Browser.new
b.goto 'http://ranktrackr.net'
b.div(:id => 'jumbo').screenshot("jumbo.png")
Any idea what is the problem? How can we fix it?
In my case, same issue, but div had neither specific width nor height. Specifying a full-size resolution when opening the Browser seems to do the trick to grab the screenshot:
browser = Watir::Browser.new :chrome
browser.window.resize_to(1900, 1080)