Web自动化测试项目(五)测试功效通知
标签:
一、邮件通知使用第三方邮件发送库yagmail
github地点:https://github.com/kootenpv/yagmail
安置
pip3 install yagmaildemo.py
import yagmail # password为登陆暗码或者授权码,yagmail SSL默认开启 yag = yagmail.SMTP(user='[email protected]', password='xxxxxxx', host='smtp.163.com') to = '[email protected]' subject = 'This is obviously the subject' body = 'This is obviously the body' html = '<a href=http://www.mamicode.com/"https:/pypi.python.org/pypi/sky/">Click me!</a>' yag.send(to=to, subject=subject, contents=[body,html])在config目录下添加mail_config.ini配置文件
[163mail] [email protected] password=XXXXXX host=smtp.163.com [project_member] # 测试人员1 [email protected] # 测试人员2 [email protected]在utils目录下添加mail_utils.py
mail_utils.py
更新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]) 二、钉钉通知 有空再写
Web自动化测试项目(五)测试功效通知
,温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/30941.html