【iTestCat】Selenium+Python3+mac os环境搭建(selenium+python3教程)

1.安装python3环境

根据下面的地址,直接一键安装,全部默认方式。

下载地址:http://www.python.org/ftp/python/

mac os自带python 2.7版本,如果你想使用自己安装的python版本,你还需要配置环境

通常建议去修改~/.bash_profile来设置环境变量,它是用户级的设置,只对当前用户有效。

操作步骤:1)、打开Terminal(终端)

【iTestCat】Selenium+Python3+mac os环境搭建(selenium+python3教程)

这里推荐一个可以比官方Terminal更好用的iTerm2

【iTestCat】Selenium+Python3+mac os环境搭建(selenium+python3教程)

下载地址:https://www.iterm2.com/downloads.html

2)、输入:vi ~/.bash_profile

【iTestCat】Selenium+Python3+mac os环境搭建(selenium+python3教程)

3)、设置PATH:

键盘输入按i,再按照以下进行设置:

# Setting PATH for Python 3.6

# The original version is saved in .bash_profile.pysave

PATH=”/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}”

export PATH

【iTestCat】Selenium+Python3+mac os环境搭建(selenium+python3教程)

4)、按esc退出编辑模式,输入::wq ? ?//保存并退出 (注意在vi下)

【iTestCat】Selenium+Python3+mac os环境搭建(selenium+python3教程)

5)、修改立即生效:source ~/.bash_profile

6)、查看环境变量的值:echo $PATH

【iTestCat】Selenium+Python3+mac os环境搭建(selenium+python3教程)

注意:

1、~/.bash_profile中有个点

2、如果是新增环境变量或者是修改环境变量的值,都需要source一下才能立即生效。如果是删除一个环境变量,必须输入exit以logout当前shell,然后再重新打开一个新的shell并login才能生效

2.安装selenium

终端输入pip -V或pip3 -V 确认是否安装成功

【iTestCat】Selenium+Python3+mac os环境搭建(selenium+python3教程)

进入终端输入pip install -U selenium

【iTestCat】Selenium+Python3+mac os环境搭建(selenium+python3教程)

注:在mac os中默认安装的是python2,如果你安装的是python3,需要使用pip3 install -U selenium

3.下载chromedriver

下载地址:http://chromedriver.chromium.org/downloads

【iTestCat】Selenium+Python3+mac os环境搭建(selenium+python3教程)

注:chrome版本与chromedriver支持版本需要对应,否则会出现无法调用chrome浏览器的情况。

4.配置chromedriver

将chromedriver复制至/usr/bin,输入命令:

Sudo cp Downloads/chromedriver /usr/bin

如果出现下图提示:

【iTestCat】Selenium+Python3+mac os环境搭建(selenium+python3教程)

是因为mac os 10.11以上系统版本需要开启系统文件写入权限。

开启mac os系统写入权限

开机时按command+r,在实用工具里找到终端,

【iTestCat】Selenium+Python3+mac os环境搭建(selenium+python3教程)

输入命令:

【iTestCat】Selenium+Python3+mac os环境搭建(selenium+python3教程)

csrutil disable

reboot

再通过命令将chromedriver复制至/usr/bin,如下图:

【iTestCat】Selenium+Python3+mac os环境搭建(selenium+python3教程)

5.验证chromedriver配置

通过访达-> 前往 ->前往文件夹 ->输入/usr/bin ->前往

【iTestCat】Selenium+Python3+mac os环境搭建(selenium+python3教程)

你直接搜索找到chromedriver说明你已经配置成功了,如下图:

【iTestCat】Selenium+Python3+mac os环境搭建(selenium+python3教程)

6.一个简单的脚本

启动chrome浏览器并打开iTestCat网站

原创文章,作者:iTestCat,保留所有权利,禁止转载,如若转载,请联系作者!

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
iTestCat的头像iTestCat
上一篇 2018年6月1日 下午8:28
下一篇 2018年6月2日 下午4:10

相关推荐

发表回复

登录后才能评论
Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Paito HK Toto4d Toto4d Paito Hk
Toto Slot
Toto Slot
Toto Slot
Toto Slot
Toto Slot
Togel Slot
SLOT GACOR
slot gacor
ts77casino
slot demo
slot dana
slot dana
Toto Slot
Situs Slot Online
Toto Slot
Toto Slot
situs slot online
slot maxwin
slot bola
slot bola
Toto Slot
slot88 gacor
bacan4d
Toto Slot
slot gacor
Slot Toto
slot gacor
Agen Slot Toto
slot gacor
Toto Slot
Situs Toto
toto gacor
Slot Online
slot qris
situs toto
https://himmahnw.id/
slot gacor
situs toto
slot toto
slot gacor
scatter hitam
situs slot online
situs slot online
pg soft mahjong 2
situs slot
situs slot
toto slot
situs toto
Toto Slot Gacor Akun Toto Akun Toto Akun Toto Akun Toto Situs Toto Akun Toto Akun Toto slot gacor slot gacor slot gacor terminal4d toto slot toto slot toto slot toto slot toto 4d
Toto SLot Toto SLot Toto SLot Togel Slot Togel Slot Toto Slot Toto Slot Toto Slot Toto Slot Toto Slot Toto Slot
Toto SLot Toto SLot
Toto Slot
https://hamadtrainingcenter.com/
https://keepod.it/
https://orologilegno.it/
https://metaldetectoronline.it/
https://winestation.it/
https://armandotravaglini.it/
https://digitalmarketingturistico.it/
https://gotodigitally.it/
situs slot
https://rockequipinc.com/
https://123jumping.com/
https://hancockcrimestoppers.org/
https://neuroscienceresearchlab.org/
https://sailingthe7zs.com/
https://pepelearningstudyportal.com/
https://arkinteriorsolutions.com/
https://shreeuniqueschool.com/
https://shreetherapy.com/
https://pepwhiz.com/
slot88
slot gacor
https://peptextandmore.com/
https://jainfoundation.in/
https://www.erflandscaping.co.uk/
https://sherrylynnespinosa.com/
https://nepalmarathons.com/
https://cciadvisory.org/
https://ablueservices.com/
situs slot
link slot
situs slot
situs slot
https://sanjoseedu.org/
https://quebradasyauco.org/
https://tap.bio/@terminal4dgacorr
https://rosariocialesedu.org/
https://rosariovegabajaedu.org/
situs slot
situs slot
situs slot
situs slot online
situs slot
situs slot
https://istanbulatakoyescort.net/
situs slot
https://letskini.com/
situs slot
situs slot
slot dana
situs slot
situs slot
agen slot
situs slot
situs slot
https://humas.unmuhbandung.ac.id/