# 一、先解决低版本谷歌浏览器打开自启系统默认浏览器设置,方法如下
https://www.zhihu.com/question/607599208/answer/3088756294
# 二、改变谷歌浏览器名字后正常运行程序,方法如下
没有任何其他操作直接运行程序,如下报错,因为没找到浏览器文件,按照上面链接的指定浏览器绝对路径。
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
from selenium import webdriver
option = webdriver.ChromeOptions()
option.binary_location=r"xxxxxx/google.exe" # binary_location属性指定Chrome启动文件
driver = webdriver.Chrome(r"xxxxxxxx\chromedriver.exe" , options=option) # 制定chromedriver.exe驱动位置
driver.get("http://www.baidu.com")
print(driver.current_url)