[Chrome Headless + Python] 截长图 (Take Full-page Screenshot)

# -*- coding: utf-8 -*-
import time
import os from selenium import webdriver
from selenium.webdriver.common.keys import Keys jenkinsJobName=os.getenv("JOB_NAME")
url="http://*.*.*.*/test.html"
print url
save_fn="testResult.PNG" option = webdriver.ChromeOptions()
option.add_argument('--headless')
option.add_argument('--disable-gpu')
option.add_argument("--window-size=1280,1024")
option.add_argument("--hide-scrollbars") driver = webdriver.Chrome(chrome_options=option) driver.get(url)
print(driver.title) scroll_width = driver.execute_script('return document.body.parentNode.scrollWidth')
scroll_height = driver.execute_script('return document.body.parentNode.scrollHeight')
driver.set_window_size(scroll_width, scroll_height)
driver.save_screenshot(save_fn)
driver.quit()

  

上一篇:hibernate 映射 多对一


下一篇:Python3 字典 fromkeys()方法