環境:ubuntu14.04, python2.7 selenium2.0
文章參考出處:http://blog.csdn.net/heybob/article/details/52922645
chromedriver(Chrome瀏覽器):我的谷歌瀏覽器版本 62.0.3202.89下載的驅動為V2.31
http://chromedriver.storage.googleapis.com/index.html
geckodriver(Firefox瀏覽器)我的火狐瀏覽器版本Firefox 57.0下載的驅動為V0.190
https://github.com/mozilla/geckodriver/releases
1.查看谷歌瀏覽器的版本:chromium-browser -version
1.1查看firefox的版本:firefox -v
2.將chromedriver下載解壓然后放到/usr/bin,然后加上執行權限,命令如下:
$ unzip chromedriver_linux64.zip
$ sudo mv chromedriver /usr/bin/
cd /usr/bin/
sudo chmod a+x chromedriver
2,測試
- from selenium import webdriver
- driver = webdriver.Chrome()
- # driver = webdriver.Firefox()
- driver.get('http://www.baidu.com')
- print driver.title
- driver.quit()
4,后記
再次執行測試代碼成功,說明selenium基本安裝成功了。另一個geckodriver也是一樣
找了半天安裝selenium的博客,但是沒看到幾個ubuntu下關於driver的具體安裝的,所以我這里記錄下。
python IDLE端測試結果如下:
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>
百度一下,你就知道
>>>