splinter icon indicating copy to clipboard operation
splinter copied to clipboard

Generate nicer error when screenshot is used on an element with 0 height (or width).

Open rouilj opened this issue 6 years ago • 1 comments

In: https://github.com/cobrateam/splinter/issues/808#issuecomment-702506449 a solution to a crash was discussed. The cause was screenshot was being used on an element that had a 0 dimension.

Script and full traceback are on #808 . Abbreviated error and location are:

E               SystemError: tile cannot extend outside image

at

/usr/local/lib/python3.6/dist-packages/PIL/ImageFile.py:514: SystemError

It would be good to capture this error and see if splinter can determine of the height and/or width are 0. In this case emit a useful error like:

   element selected by ..... has 0 height and can't be screenshotted. Try using a child or parent element.

and a similar error for width.

Thanks.

rouilj avatar Oct 07 '20 00:10 rouilj

WebDriverElement.screenshot() has been refactored to use selenium's element capture instead of using pillow to crop a screenshot. A 0 width/height screenshot will now raise an error message from Selenium.

javascript-error avatar Apr 06 '22 15:04 javascript-error