UI自动化测试入门一:Python3+Selenium环境搭建

自动化测试主要是将手工测试内容转换自动化来实现。目前主流的自动化都是基于Selenium+Webdriver来实现的。

1、安装Python

2、安装Pycharm

3、安装selenium

安装selenium比较简单,直接在cmd输入"pip install selenium"

备注:如果默认得国外地址下载失败的话,pip 命令中可以使用 -i 参数来指定镜像地址

pip install selenium -i https://pypi.tuna.tsinghua.edu.cn/simple    #指定了国内清华大学的源

国内源地址:

  • 中国科学技术大学 : https://pypi.mirrors.ustc.edu.cn/simple
  • 豆瓣:http://pypi.douban.com/simple/
  • 清华大学:https://pypi.tuna.tsinghua.edu.cn/simple

4、安装Webdriver

webdriver要和想要用的浏览器、浏览器版本要一致。

chrome webdriver下载地址:

http://chromedriver.storage.googleapis.com/index.html

本次以chrome举例,我电脑上的chrome浏览器版本是83.0.4103.97,所以从下面选择了最为接近的版本。

我本机是windows,选择驱动如下:

将上图中的zip文件下载后解压后得到chromedriver.exe文件,将该文件放到python根目录下即可。

原文地址:https://www.cnblogs.com/daydayup-lin/p/15196454.html