我正在尝试使用 Chromedriver 和非默认配置文件加载 Chrome。
我正在使用这个 python 代码:
opt = webdriver.ChromeOptions()
chromedriver = r"C:/chromedriver/chromedriver.exe"
os.environ["webdriver.chrome.driver"] = chromedriver
opt.add_argument(r"user-data-dir=C:\Users\user\AppData\Local\Google\Chrome\User Data\Default_Selenium")
driver = webdriver.Chrome(opt)
但我收到以下错误:
Traceback (most recent call last):
File "C:\Users\user\workspace\dd\src\start.py", line 29, in <module>
main()
File "C:\Users\user\workspace\dd\src\start.py", line 20, in main
driver = webdriver.Chrome(opt)
File "C:\Python27\Lib\site-packages\selenium-2.43.0-py2.7.egg\selenium\webdriver\chrome\webdriver.py", line 59, in __init__
self.service.start()
File "C:\Python27\Lib\site-packages\selenium-2.43.0-py2.7.egg\selenium\webdriver\chrome\service.py", line 68, in start
and read up at http://code.google.com/p/selenium/wiki/ChromeDriver")
selenium.common.exceptions.WebDriverException: Message: 'ChromeDriver executable needs to be available in the path. Please download from http://chromedriver.storage.googleapis.com/index.html and read up at http://code.google.com/p/selenium/wiki/ChromeDriver'
我究竟做错了什么?