selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PAT
用webdrive打开chorme浏览器时,出现错误:selenium.common.exceptions.WebDriverException: Message: ‘chromedriver’ executable needs to be in PAT
# -*- coding: utf-8 -*-
from selenium import webdriver
if __name__ == '__main__':
#browser = webdriver.Chrome(r'C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe')
browser = webdriver.Chrome()
browser.get("https://www.baidu.com") # 此时会打开chrome浏览器,且网页是www.baidu.com
browser.close() # 关闭浏览器
从网上查了一下,有两个方法:
1.把chromedriver.exe路径传给Chrome()函数。
2.把chromedriver.exe文件放到C:\Windows\System32里(windows 10)。
另外chromedrive.exe版本的选择及下载请参考:
https://www.cnblogs.com/JHblogs/p/7699951.html
https://www.cnblogs.com/technologylife/p/5829944.html
还没有评论,来说两句吧...