上次使用Selenium+Python還是好幾個月前了
今天想再用一下,結果寫個打開網站的小demo報錯,報錯如下:
檢查了一下,查看報錯日志,應該是chrome版本和driver版本不一致導致的。
於是要重新下載對應的新的driver版本。
1、查看自己chrome版本如下:
2、安裝webdriver
各大瀏覽器webdriver地址可參見:
https://docs.seleniumhq.org/download/
Firefox: https://github.com/mozilla/geckodriver/releases/
Chrome: https://sites.google.com/a/chromium.org/chromedriver/ 或者
http://chromedriver.storage.googleapis.com/index.html
IE: http://selenium-release.storage.googleapis.com/index.html
注:webdriver需要和對應的瀏覽器版本以及selenium版本對應
Firefox: https://github.com/mozilla/geckodriver/releases/
Chrome: https://sites.google.com/a/chromium.org/chromedriver/ 或者
http://chromedriver.storage.googleapis.com/index.html
IE: http://selenium-release.storage.googleapis.com/index.html
注:webdriver需要和對應的瀏覽器版本以及selenium版本對應
3、找到和我chrome版本相對應的driver版本並下載。

4、webdriver安裝路徑
Win:復制webdriver到Python安裝目錄下
Mac:復制webdriver到/usr/local/bin目錄下
5、復制完成后重啟pycharm
重新執行剛才的腳本,可以正常調起瀏覽器。
6、備注:
再日常用的時候可以關閉chrome的自動更新。
端午節安康!
一起加油吧!