python+selenium运行测试用例并邮件发送测试结果

本文介绍如何使用Python结合Selenium库执行自动化测试用例,并详细阐述了如何将测试结果通过邮件的方式进行发送,以便于团队成员查看和分析测试状况。
摘要由CSDN通过智能技术生成

版权声明:本文为博主原创文章,转载需经作者同意!!

import unittest
import os
from email.mime.text import MIMEText
from email.header import Header
import smtplib
import time
import HTMLTestRunner

#获取测试套件函数
def test_suite(file_path):
	test_unit = unittest.TestSuite()
	#利用discover获得所有的测试用例,测试用例都是以start_开头
	discover = unittest.defaultTestLoader.discover(file_path, pattern='start_*.py', top_level_dir=None)
	for testsuite in discover:
		for testcase in testsuite:
			test_unit.addTest(testcase)
	return test_unit

#获取最新的测试结果函数
def newest_report(file_path):
	report_lists = os.listdir(file_path)
	report_lists.sort(key=lambda fn: os.path.getmtime(file_path+fn) if not os.path.isdir(file_path+fn) else 0)
	new_report_dir = os.path.join(file_path, report_lists[-1])
	return new_report_dir
	
#发送邮件函数
def send_mail(new_report):
	sender = 'abc@qq.com'
	receiver = 'xyz@qq.com'
	subject
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值