遇到的问题:
使用python2.7进行系统自动化,本来已经支持高版本google版本,但是需求改变,需要使用低版本google浏览器才能使用系统的控件。故需要降低google版本和selenium版本。
找到google低版本的googledriver,网上只有现在google浏览器对应googledriver的匹配数据,但是无法对应selenium的版本,反正我还没找到。不过应该大家学习和使用,都用最新版本。
解决方案:看googledriver的发布时间对应最近的selenium的版本。
(38google浏览器现在使用的2.12googledriver,2.44 selenium,经验证可以成功。)最新尝试,如果使用3.43的selenium也是支持的。因此selenium的版本同googledriver的版本是可以随意使用的
--------------------------------------------------------------------------------------------------------------
但是启动后报错了:“unknown error: cannot find Chrome binary”
解决方案:
1、确认google浏览器版本是否只存在一个(之前我们有个高版本的没有卸载。需要卸载,只保留38的版本)
2、需要将googledriver放入google38版本的安装路径下(与chrome.exe同级目录),并配置环境变量。
3、驱动要写清具体调用的路径()
from selenium import webdriver
driver = webdriver.Chrome()-----------这个要改成driver = webdriver.Chrome(‘"C:\Program Files (x86)\Google\Chrome\Application\googledriver.exe"’)
driver.get("http://www.baidu.com")
就妥妥的啦。
--------------------------------------------------------------------------------------------------------------
selenium各版本下载地址:
http://selenium-release.storage.googleapis.com/index.html
IE驱动下载地址:
http://selenium-release.storage.googleapis.com/index.html
google驱动下载地址:
http://chromedriver.storage.googleapis.com/index.html
火狐驱动下载地址:
https://github.com/mozilla/geckodriver/releases
--------------------------------------------------------------------------------------------------------------
selenium有个初学地址,我觉得还不错,可以参考。
http://www.selenium.org.cn/1598.html
如果遇到其他问题,也可留言,互相交流。