从零开始搭建python+selenium+pytest+allure

1、首先安装python安装包:Welcome to Python.org

我这里选择的是windows3.9.6安装包

从零开始搭建python+selenium+pytest+allure

下载后正常双击安装就好

从零开始搭建python+selenium+pytest+allure

建议不要安装到C盘或非应为路径下可能会出现问题

1.1环境变量的配置

从零开始搭建python+selenium+pytest+allure

在环境变量将自己安装的python路径添加到环境变量中

通过cmd验证一下是否已经配置好

从零开始搭建python+selenium+pytest+allure

如果出现这个界面就表示已经安装好了

2、安装selenium

在cmd界面输入pip install selenium来安装最新版本软件。

从零开始搭建python+selenium+pytest+allure

通过pip selenium show来查看是否安装成功和安装的版本,我这里安装的3.141.0版本

从零开始搭建python+selenium+pytest+allure

如果想安装低版本的需要安装时pip isntall selenium = “版本号”

至此,安装的python环境和selenium就安装好了

3、安装webdriver

安装好以上环境后需要安装对应浏览器的驱动程序,因为我用的selenium版本较高所以firefox和chorme都需要安装驱动,如果是2.xxx版本应该是不需要按照firefox驱动的(没有实验)

下载链接:

Chrome

点击下载chrome的webdriver: http://chromedriver.storage.googleapis.com/index.html

Firefox

Firefox驱动下载地址为:Releases · mozilla/geckodriver · GitHub

IE

IE浏览器驱动下载地址为:http://selenium-release.storage.googleapis.com/index.html

根据需要下载对应的驱动就好,下载好后建议将驱动放到上面说的python安装路径下,这样就省的添加一次环境变量了

从零开始搭建python+selenium+pytest+allure

4、安装pycharm

从官网下载 :PyCharm: the Python IDE for Professional Developers by JetBrains

可以选择免费的,当然如果下载需要破解的可以自己查找破解方法,网上还是挺多的

5、到这里基本可以调用浏览器进行一些简单的操作了,不过还是要选择一下自动化测试框架

这里选择的是pytest+allure

5.1安装pytest

从零开始搭建python+selenium+pytest+allure

因为我这里已经安装了,所以会显示 Requirement already satisfied:

从零开始搭建python+selenium+pytest+allure

5.2安装allure

下载地址:https://github.com/allure-framework/allure2/releases

从零开始搭建python+selenium+pytest+allure

根据自己的需要进行下载,然后解压

从零开始搭建python+selenium+pytest+allure

点击bin目录下的bat会出现一闪而过的配置界面

然后给自己的allure配置环境变量

参照给python的配置就可以了

从零开始搭建python+selenium+pytest+allure

至此整个环境就配置好了

可以开始自己的自动化测试进程了

从零开始搭建python+selenium+pytest+allure

成品

Original: https://blog.csdn.net/weixin_44277941/article/details/119183136
Author: 春仲逢秋
Title: 从零开始搭建python+selenium+pytest+allure

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/772944/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球