自动下载并安装支持当前安装的chrome版本的chromedriver。此安装程序支持Linux、MacOS和Windows操作系统。
安装
pip install chromedriver-autoinstaller
用法 只需在要使用chromedriver的模块中键入import chromedriver_autoinstaller。
示例
from selenium import webdriver
import chromedriver_autoinstaller
chromedriver_autoinstaller.install() # Check if the current version of chromedriver exists
# and if it doesn't exist, download it automatically,
# then add chromedriver to path
driver = webdriver.Chrome()
driver.get("http://www.python.org")
assert "Python" in driver.title