一、邮件通知

使用第三方邮件发送库yagmail

github地址:https://github.com/kootenpv/yagmail

安装

pip3 install yagmail

demo.py

import yagmail
# password为登陆密码或者授权码,yagmail SSL默认开启
yag = yagmail.SMTP(user='xxxxxx@163.com', password='xxxxxxx', host='smtp.163.com')
to = 'xxxxxx@qq.com'
subject = 'This is obviously the subject'
body = 'This is obviously the body'
html = '<a href="https://pypi.python.org/pypi/sky/">Click me!</a>'
yag.send(to=to, subject=subject, contents=[body,html])

在config目录下添加mail_config.ini配置文件

[163mail]
user=XXXXXX@163.com
password=XXXXXX
host=smtp.163.com [project_member]
# 测试人员1
ceshi_1=XXXXXX@qq.com
# 测试人员2
ceshi_2=XXXXXX@qq.com

在utils目录下添加mail_utils.py

mail_utils.py

import yagmail
import configparser
import os mail_config_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + '/config' + '/mail_config.ini'
mail_config = configparser.ConfigParser()
mail_config.read(mail_config_path) user = mail_config['163mail']['user']
password = mail_config['163mail']['password']
host = mail_config['163mail']['host'] def send_mail(to, subject, contents, user=user, password=password, host=host):
'''https://github.com/kootenpv/yagmail'''
yag = yagmail.SMTP(user=user, password=password, host=host)
yag.send(to=to, subject=subject, contents=contents)

更新run_login_case_report.py,调用发送报告

import unittest
import configparser from module_path import *
from test_case.test_login import TestLoginCase
from utils.se_utils import Driver
from utils.HTMLTestRunnerChart import HTMLTestRunner
from utils.mail_utils import send_mail if __name__ == '__main__':
###### 执行测试用例 ######
cases = unittest.TestLoader().loadTestsFromTestCase(TestLoginCase)
runner = HTMLTestRunner(
title="自动化测试报告",
description="%s ,%s" % (Driver.get_driver().name, cul_platform),
stream=open(report_path, "wb"),
verbosity=2,
retry=0,
save_last_try=True)
runner.run(cases) # 所有用例运行完后关闭浏览器
Driver.quit_driver() ###### 邮件发送 ######
config = configparser.ConfigParser()
config.read(mail_config_path)
project_member = config.items('project_member') subject = 'Web Ui 自动化测试报告'
body = '正文内容'
to = project_member_list = [x[1] for x in project_member]
html = open(report_path, 'r', encoding='utf-8').read()
file = report_path
send_mail(to=to, subject=subject,
contents=[file])

二、钉钉通知

有空再写

最新文章

  1. 立即执行函数表达式(IIFE)
  2. ON DUPLICATE KEY UPDATE重复插入时更新
  3. jQuery原型属性和方法总结
  4. POJ3260The Fewest Coins[背包]
  5. @Autowired @Resource用法
  6. Cron 表达式详解和案例
  7. ecshop增加pc扫描二维码微信支付功能代码
  8. Java知识总结--数据库
  9. URAL 1146 Maximum Sum(最大子矩阵的和 DP)
  10. 数据结构 - 堆排序(heap sort) 具体解释 及 代码(C++)
  11. C语言入门(16)——C语言的数组
  12. 自然语言处理(NLP)常用开源工具总结(转)
  13. Arch Linux 安装过程
  14. 单发邮箱 群发邮箱 程序 Email winform
  15. Java运行时环境---ClassLoader类加载机制
  16. Ubuntu18.04安装Guake下拉式终端
  17. mariadb-半同步复制
  18. python 常用模块之random,os,sys 模块
  19. Matlab 2016b 正式版下载
  20. 【连接】Spring事物的传播行为

热门文章

  1. SSI(服务器端嵌入)
  2. JMM中的Happens-Before原则
  3. JAVA优化篇 如何找到运行缓慢的线程
  4. $CH5104\ I-country$ 线性$DP$
  5. status100到500http响应对应状态解释
  6. RAID阵列
  7. (三)Django模板语言
  8. Essential C++学习笔记
  9. 【转】ArcGIS ADF 实时轨迹问题初步解决方案
  10. NOIP2004普及组第3题 FBI树