第一个web自动化脚本--mac下打开浏览器
2019-08-01 本文已影响0人
花开闪亮
一、打开浏览器自带safari浏览器

二、打开chrome浏览器
打开chrome浏览器,需要下载驱动。
1.Chromedriver驱动下载:

下载地址:
http://chromedriver.storage.googleapis.com/index.html
https://www.npmjs.com/package/chromedriver
http://npm.taobao.org/mirrors/chromedriver/
版本不对应,也会报错
2.将驱动文件放入到 usr/local/bin目录下
cd /usr/local/bin
open .
然后将下载的文件拖进目录里

3.检查拖入是否生效
chromedriver --version
会输出对应版本信息

4.配置环境变量
配置环境变量后在使用webdriver时不指定chromedriver也可以使用,不配置需要指定路径
cd ~
touch .bash_profile
open -e .bash_profile
会打开变量文件 ,输入path路径
PATH="/usr/local/bin/ChromeDriver:${PATH}"
export PATH
保存文件
5.使用刷新配置命令刷新文件,使文件生效
source ~/.bash_profile
6.使用webdriver启动chorme

启动成功!
撒花~~~~