Duc*_*her 2 python selenium automation selenium-chromedriver
我正在使用selenium和python,我正在尝试使用一些参数来启动chromedriver.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options as ChromeOptions
def buildDriver():
options = ChromeOptions()
options.add_argument('--profile-directory="Default"')
options.add_argument('--user-data-dir="C:/Temp/ChromeProfile"')
browser = webdriver.Chrome(chrome_options=options)
driver = buildDriver()
Run Code Online (Sandbox Code Playgroud)
我无法找到以下错误的解决方案:
selenium.common.exceptions.WebDriverException:消息:未知错误:无法创建默认配置文件目录
谷歌搜索这个错误不会导致任何有意义的事情,至少对我没有意义.
事实证明,添加参数时不能使用引号.
options.add_argument('--profile-directory=Default')
options.add_argument('--user-data-dir=C:/Temp/ChromeProfile')
Run Code Online (Sandbox Code Playgroud)
请注意,它--profile-directory=Default不是--profile-directory="Default"
这就是为我解决问题的原因.