playwright + pytest + python310 + allure UI自动化测试框架简介
·
1、目录创建
config目录存放环境配置信息,data目录存放测试数据,logs目录存放日志,testcase存放测试用例,trace目录存放trace信息,utils目录存放封装的包。

2、设计数据输入类型的用例,可在yaml文件中录入输入的数据集,然后用封装好的YamlReader方法读取。(以登陆real python网站为例)



YamlUtil和logUtil的封装参考了B站UP主“吃葡萄不吐葡萄皮honey”的视频,致敬!

3、对于页面元素检查和操作的UI自动化用例, 可以现在conftest文件中定义登陆页面的fixture,将page对象yield出来,并safe teardown,且在teardown中保存trace日志,然后设置scope为class,然后在testcase中直接引用。具体思路参考pytest官网。



4、运行用例并生产allure报告


浏览器打开生成的index.html文件

PS:附上常用命令
通过pytest命令生成 allure报告
pytest test_loginRP.py --alluredir ./report/result
生成allure报告
allure generate report/result -o report/html --clean
查看trace文件的命令
playwright show-trace 20240430180442607520.zip
代码产生模式
playwright codegen https://realpython.com
更多推荐

所有评论(0)