watir-extensions-element-screenshot icon indicating copy to clipboard operation
watir-extensions-element-screenshot copied to clipboard

Original image height is too small! (ChunkyPNG::OutOfBounds)

Open anilreddy opened this issue 11 years ago • 6 comments

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 `

'

anilreddy avatar Jun 05 '14 04:06 anilreddy

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 avatar Jun 11 '14 19:06 ansoni

@ansoni i am using chrome browser and the element has height of 250 * width 350

anilreddy avatar Jun 12 '14 13:06 anilreddy

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?

Liiva avatar Jul 31 '14 13:07 Liiva

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.

Liiva avatar Aug 07 '14 08:08 Liiva

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?

introvert avatar Nov 06 '14 18:11 introvert

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)

malditojavi avatar Dec 27 '15 11:12 malditojavi