How to convert HTML Report to picture format in Email? So that we can see the automation report also at home or on mobile phone anywhere.We tried to use phantomJs to get the full-page screenshot of H...
How to convert HTML Report to picture format in Email? So that we can see the automation report also at home or on mobile phone anywhere.
We tried to use phantomJs to get the full-page screenshot of HTML, it doesn't work well on some computers, then we found that the newest Chrome doesn't support it anymore, and Chrome has use its Headless mode to replace phantomJs.
Version 1 : phantomJs
# -*- coding: utf-8 -*-
import time
import os
from selenium import webdriver
jenkinsJobName=os.getenv("JOB_NAME")
url="http://10.249.4.17/testRailAgent/AutoAnaylsisReport.html"
print url
save_fn="buildNumResult.PNG"
driver = webdriver.PhantomJS()
driver.maximize_window()
driver.get(url) # Load page
time.sleep(30)
driver.save_screenshot(save_fn)
driver.close()
time.sleep(5)
os.system("taskkill /F /IM phantomjs.exe")
Version 2: Chrome Headless
# -*- coding: utf-8 -*-
import time
import os
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
url="http://10.249.4.17/testRailAgent/BillingAnaylisisReport.html"
print url
save_fn="buildNumResult.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()
本文标题为:How to convert HTML Report to picture format in Email?
基础教程推荐
- 分页技术原理与实现之无刷新的Ajax分页技术(三) 2023-01-20
- layer.open()详细参数对照说明 2023-07-09
- vue中mixins的使用方法和注意点 2023-10-08
- $.ajax()常用方法详解(推荐) 2023-01-20
- 使用Ajax实现简单的带百分比进度条实例 2023-02-14
- 微信小程序获取头像和昵称的最新方法(直接用!) 2023-08-08
- HTML5 新增标签(一) 2023-10-27
- 第4天:调用样式表 2022-11-04
- 【Layui】当Layui数据表格和Layui下拉框组合时发生的问题 2022-12-14
- Ajax跨域请求COOKIE无法带上的完美解决办法 2023-02-01