selenium 截图

http://blog.csdn.net/u010953692/article/details/78320025

# coding:utf-8
# coding:cp936
from selenium import webdriver
from PIL import Image

broswer = webdriver.Chrome()
broswer.get("http://www.baidu.com")
broswer.save_screenshot(r'E:photo.png')
baidu = broswer.find_element_by_id('su')
left = baidu.location['x']
top = baidu.location['y']
elementWidth = baidu.location['x'] + baidu.size['width']
elementHeight = baidu.location['y'] + baidu.size['height']
picture = Image.open(r'E:photo.png')
picture = picture.crop((left, top, elementWidth, elementHeight))
picture.save(r'E:photo2.png')

  

原文地址:https://www.cnblogs.com/xqnq2007/p/8037232.html