转载地址:https://www.jianshu.com/p/39716ea15d99?utm_source=oschina-app
安装 selenium
☁ ~ pip3 install selenium
☁ ~ pip3 list selenium
Package Version
---------- -------
pip 18.0
selenium 3.14.0
setuptools 40.2.0
urllib3 1.23
wheel 0.31.1
安装 ChromeDriver
到官网查看最新版本
查看最新版本与chrome的匹配
![](https://upload-images.jianshu.io/upload_images/1864602-e85ddb9614b63eb2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/854)
ChromeDriver 2.41
查看chrome版本
![](https://upload-images.jianshu.io/upload_images/1864602-b4d0e32fdc66fcbf.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/727)
chrome版本
根据自己的操作系统下载相应安装包
可以选择到淘宝镜像下载
下载后,将安装包加入到环境变量。以mac系统为例,将chromedriver移至/usr/bin目录下即可
验证安装
☁ ~ chromedriver
Starting ChromeDriver 2.41.578706 (5f725d1b4f0a4acbf5259df887244095596231db) on port 9515
Only local connections are allowed.
测试能否调用chrome
☁ ~ ipython
Python 3.7.0 (default, Aug 22 2018, 15:22:33)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.5.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from selenium import webdriver
In [2]: browser = webdriver.Chrome()
In [3]: