【Python 库】Selenium 浏览器驱动

  Selenium是一个用于测试网站的自动化测试工具,爬虫中也经常用到,支持各种浏览器包括Chrome、Firefox、Safari等主流界面浏览器,同时也支持phantomJS无界面浏览器。

  自WebDriver 3.0 之后,Selenium不再提供默认的浏览器支持。换言之,不再默认地支持Firefox了。用FireFox测试, 就需要用FireFox的驱动才行。

  驱动下载后,放到Python安装目录的Scripts文件夹下(相当于变相添加环境变量)。

  chromedriver、IEDriverServer等浏览器测试驱动都是调用系统的谷歌、IE浏览器,所以驱动和浏览器客户端必须相互匹配。

1Chrome驱动 chromedriver

chromedriver没有64位版本,32即可驱动

https://sites.google.com/a/chromium.org/chromedriver/downloads

这个地址被墙了,可以用以下地址下载:

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

http://npm.taobao.org/mirrors/chromedriver/

chromedriver 和支持的 Chrome 版本对照表

v2.40

v66-68

v2.39

v66-68

v2.38

v65-67

v2.37

v64-66

v2.36

v63-65

v2.35

v62-64

v2.34

v61-63

v2.33

v60-62

v2.32

v59-61

v2.31

v58-60

v2.30

v58-60

  

2FireFox驱动 gechodriver

https://github.com/mozilla/geckodriver/releases

这个地址也被墙了,CSDN上下载了一个,版本号是v0.20.1

 

3IE驱动 IEDriverServer

http://selenium-release.storage.googleapis.com/index.html

淘宝镜像地址:https://npm.taobao.org/mirrors/selenium/

IE驱动没有找到版本对应,测试了下貌似是向下兼容的。测试环境:IE8,IEDriverServer2.5 和 3.9版本,都可以运行。

用IE浏览器可能会报一个错:Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones.

工具 -> Internet选项 -> 安全,四个区域的“启用保护模式”设置必须一致,要么全选,要么全不选。

 

4、其它的驱动

参考官网,能想到的驱动都在这里了。

http://www.seleniumhq.org/download/

原文地址:https://www.cnblogs.com/gl1573/p/9447070.html