# pytestui **Repository Path**: yuhui-zhang/pytestui ## Basic Information - **Project Name**: pytestui - **Description**: 基于Pytest的UI测试自动化 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2022-05-05 - **Last Updated**: 2022-05-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # PyTestUI 基于Pytest、Allure、Xpath的测试自动化工程 采用pytest ,实例、类的命名必须还有test case -- 实例 conftest.py 驱动浏览器的代码写在一个全局的conftest.py文件里面 注意: 项目使用Pytest 必须满足命名规范 1.文件名 test-*.py或者 *_test.py 测试类 定义Class必须以Test开头,并且不能包含init方法。没有test情况下,Pytest不会执行该class common -- base.py 基于原生selenium二次封装 -- des_decrypt.py 加密解密的类 -- log.py 记录log文件 -- read_yml.py 解决yml文件的读取 pages 存放执行实例的class py文件必须有base,例如class LoginPage(Base): Pytest 是python 的第三方单元测试框架,比自带 unittest 更简洁和高效,支持315种以上的插件,同时兼容 unittest 框架。 存在的意义:为了生成测试报告、存在的唯一价值 allure // -s: 输出打印信息 // '文件名' 需要执行的测试文件 '--alluredir','../testresults/report/xml' 固定值 pytest.main('-s','文件名','--alluredir','temp') pytest.main(['-s','-q','./test_login_case.py','--alluredir','../testresults/report/xml']) // 生成测试报告 allure generate ./temp -o ./report --clean 运行配置 XPath XPath 解析XML的语言、用于解析HTML的数据不是python、java独有的。类似的 BautifulSoup、lxml、DOM、JSDOM XPath的语法 层级 / 直接子集 // 跳级 属性 @属性访问 函数 Contains() 、text()等 3.使用XPath allure参考网站: https://www.cnblogs.com/zztxiaodeng/p/10656582.html