webdriver.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:selenium-chrome-screenshot 作者: sanscore 项目源码 文件源码
def __screenshot_png(self, func):
        """Helper function that produces the screenshot.

        Produces a stitched together screenshot of the current webpage.
        Automatically hides and restores Chrome's scrollbars.

        Args:
            func: A helper function which will be passed the finalized
                screenshot. Whatever is returned by `func` is returned
                by this function.

        Returns:
            Whatever is returned by func(screenshot).
        """
        self.__scrollbars_hide()

        doc_width = self.__document_width
        doc_height = self.__document_height
        with Image(width=doc_width*2, height=doc_height*2) as screenshot:
            for data, rect in self.__iter_screenshots((doc_width, doc_height)):

                with Image(blob=base64.b64decode(data),
                           format='png') as shot:
                    screenshot.composite(image=shot,
                                         left=rect[LEFT]*2,
                                         top=rect[TOP]*2)
                del data

            _ret = func(screenshot)

        self.__scrollbars_restore()
        return _ret
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号