jeanphix/Ghost.py — pull request #180 by Vaskivo (2014-09-11 18:03:44+00:00)
Title: Fixed Ghost.capture() when using selectors/regions

For a quick preview of the fix, run

from ghost import Ghost
ghost = Ghost(wait_timeout=10)
ghost.open('https://en.wikipedia.org/wiki/Super_Mario_Bros.')
ghost.capture_to('pic.png', selector='div#mw-content-text')

with and without the fix.

The bug occured in Windows with Python 2.7

What I did:

1 - The image was getting cropped, only the top would show. I used the `setScrollBarPolicy` and `setViewportSize` as it was used without the regions.
2 - The image was getting cropped when screenshotting dinamic elements. The page had to be rendered before getting the element's region.

It is slightly less efficient, as it always renders the whole page, but it works.