# Selenium_Pytest_Allure **Repository Path**: hcemmm/selenium_-pytest_-allure ## Basic Information - **Project Name**: Selenium_Pytest_Allure - **Description**: 基于Selenium的利用PO设计理念编写的Web自动化测试框架,可多进程进行多浏览器并发测试(如谷歌,火狐等),测试报告采用allure生成。 - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 25 - **Forks**: 5 - **Created**: 2020-09-26 - **Last Updated**: 2025-05-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 简介 基于selenium4+pytest+allure编写的WebUI自动化框架 + selenium4:可使用各种driver进行web自动化测试 + pytest:主流的自动化测试框架,可灵活进行测试用例编排 + allure:生成html测试报告的框架 ## 环境配置 所需环境:python3.8,allure2.0+ #### 安装python3.8 根据操作系统下载指定安装包: https://www.python.org/downloads/release/python-3810/ windows安装python3教程: https://blog.csdn.net/weixin_55154866/article/details/134027758 #### 安装allure2.0+ 下载地址:https://github.com/allure-framework/allure2/releases windows安装allure教程: 1)下载最新版本即可,如windows下载 `allure-2.25.0.zip` 2)解压文件到目录,如解压到`D:\allure-2.25.0` 3)将系统环境变量path加入allure的bin目录,如:`D:\allure-2.25.0\bin` 4)打开cmd终端,输入 ``` allure --version ``` 若显示版本号`2.25.0`则表示安装成功 #### 安装项目依赖 安装python相关库:在该项目根目录运行cmd命令 ``` pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple ``` ## 脚本结构 - config:存放全局配置文件 - data:存放项目加载的数据,如cookie - logs:脚本执行时产生的日志存放在此文件夹 - **page:由测试人员编写维护,存放项目的各个页面元素定位以及步骤方法脚本** - report:存放allure测试报告的文件夹 - **testcase:由测试人员编写维护,存放项目的各个页面的测试用例脚本** - utils:工具类,包含数据库工具类、数据转换公共工具类等,工具类的方法一般与业务无关 - conftest.py:pytest特有的测试配置⽂件,用于设置项目所需的fixture,以及Hook函数 - pytest.ini:pytest的配置文件,用于配置allure结果路径、测试用例收集规则 - requirements.txt:项目依赖项信息文件 - run.py:脚本运行主函数 ## 执行脚本 #### pycharm启动 使用pycharm打开该项目,运行`run.py`即可执行脚本 #### 查看测试报告 若直接打开`./report/allure_report/设置的驱动/index.html`文件,页面会显示Null,因为该报告需要在web服务器打开才能正常显示,所以需使用以下方法打开报告: pycharm打开该项目,在 `./report/设置的驱动/allure_report` 文件夹中,右键`index.html`文件,选择`Open in browser->chrome`即可查看测试报告