自动化测试_Mac安装python+selenium

1、下载安装(参照下文)

https://blog.csdn.net/kacylining/article/details/60587484

https://www.zhihu.com/question/30496889

a 下载 pip https://pypi.org/project/pip/#files 一定要进去下载,是要点 download files

b 一定要 cd 到解压 pip 这个文件夹  cd /Users/new/Downloads/pip-19.0.1

接下来执行这 3 条命令

sudo python setup.py install

sudo easy_install pip

sudo pip install -U selenium

 就安装好 selenium

2、写入测试代码后报错:

ModuleNotFoundError: No module named 'selenium'

https://www.cnblogs.com/sgwjj/p/8558242.html

 

3、火狐Firefox浏览器所有历史版本下载地址

http://ftp.mozilla.org/pub/mozilla.org//firefox/releases/

 

4、下载对应浏览器的驱动

https://blog.csdn.net/zxy987872674/article/details/53173208

https://docs.seleniumhq.org/download/

⚠️:一定要确保 Firefox 设置为不检查更新

报错

selenium.common.exceptions.SessionNotCreatedException: Message: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line

 原因:firefox 版本不对,下载 52 版本的(http://ftp.mozilla.org/pub/mozilla.org//firefox/releases/

下面是其他报错及其原因

https://www.cnblogs.com/get-up/p/6090253.html

 

原文地址:https://www.cnblogs.com/yaozhi/p/10309258.html