Python Selenium allure界面自动化测试

1、安装Selenium

cd到python安装路径的lib目录下,

pip install selenium

2、安装浏览器驱动:

Chrome:

https://sites.google.com/a/chromium.org/chromedriver/downloads

如果网络不行,可以到我的网盘中下载,我收集了一些,希望有用。

https://pan.baidu.com/s/1UP33MbEBM_4p1BdXTVHZqw

https://pan.baidu.com/disk/home#/all?path=%2F%E6%88%91%E7%9A%84%E8%B5%84%E6%BA%90&vmode=list

Firefox:

https://github.com/mozilla/geckodriver/releases

Edge:

https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver

Safari:

https://webkit.org/blog/6900/webdriver-support-in-safari-10

http://chromedriver.storage.googleapis.com/index.html下载对应版本的chromdriver:

使用不同的浏览器,需要下载对应驱动,并且确保驱动文件如chromedriver.exe放到你的系统环境PATH中

3、安装Pytest

cd到python安装路径的lib目录下,

pip3 install -U pytest 

4、安装allure:

pip install pytest-allure-adaptor

cd 到test_login.py所在目录,执行以下命令:

pytest test_login.py --alluredir=./result/

如果报错,执行以下操作:

pip uninstall pytest-allure-adaptor

pip install allure-pytest

5、安装allure-commandline

--先安装jdk8,https://pan.baidu.com/disk/home#/all?path=%2F%E6%88%91%E7%9A%84%E8%B5%84%E6%BA%90&vmode=list

--下载allure命令行工具,

https://github.com/allure-framework/allure2

https://pan.baidu.com/s/1LoPJQM27PfGwXWZ--bs8XQ

https://pan.baidu.com/disk/home#/all?path=%2F%E6%88%91%E7%9A%84%E8%B5%84%E6%BA%90&vmode=list

--进入bin目录,运行allure.bat

--添加allure到环境变量PATH

6、生成html测试报告:

cd到python的allure目录下执行以下操作

allure generate [reusult的路径] -o ./report/ --clean

allure open -h 127.0.0.1 -p 8083 ./report/

运行后本机的浏览器将打开 http://127.0.0.1:8083/index.html 网页,展示测试报告

Jenkins和allure报告集成:

https://blog.csdn.net/liuchunming033/article/details/79624474

你可能感兴趣的:(Python Selenium allure界面自动化测试)