python-needle / needle

Automated tests for your CSS.
https://needle.readthedocs.io/
Other
590 stars 50 forks source link

how to handle screenshot assertion of div out of the current viewport? #51

Closed andreabisello closed 8 years ago

andreabisello commented 8 years ago

Hi,

when i use needle to capture screenshot under the current viewport, screenshot becomes black.

passport-target-question

for example, if my browser has 1000px of height but the page is scrollable because its body has a height of 2000px, and my target id is in the page, but out of the area the browser can see, the screenshot becomes black.

i attached two screenshot. the test is the same, but i put a time.sleep(10) that permits to me to scroll down in the page obtaining a screenshot

passport-target-question

how should i handle this situation?

should i implement a "if not visible scroll browser to makes the div visible" ?

andreabisello commented 8 years ago

@jphalip is a bit different. in a simply webpage, screenshot will taken even outside viewport. you can see it with those test


    def test_inside_viewport(self):
        self.driver.get('https://rawgit.com/abioneperhobby/needle/master/demo/viewport.html')
        self.assertScreenshot('#inside', 'inside')

    def test_outside_viewport(self):
        self.driver.get('https://rawgit.com/abioneperhobby/needle/master/demo/viewport.html')
        self.assertScreenshot('#outside', 'outside')

i'm trying to understand what's happening

andreabisello commented 8 years ago

@jphalip closed, the problem is not the viewport, the problem is the scrollable area. opening https://github.com/bfirsh/needle/issues/53