首页 > 解决方案 > 我正在设置下载路径选项,并且仅当我将 chromdriver.v2 用作 uc 时才会出现该异常

问题描述

异常:selenium.common.exceptions.InvalidArgumentException:消息:无效参数:无法解析功能:来自无效参数的 goog:chromeOptions:无法识别的 chrome 选项:首选项

我正在使用的 Chrome 选项:

 import undetected_chromedriver.v2 as uc
 chrome_options = uc.ChromeOptions()
 chrome_options.add_argument("--window-size=800,800")
 chrome_options.add_argument("--no-sandbox")
 chrome_options.add_argument("--start-maximized")
 chrome_options.user_data_dir = project_settings.LOCAL_PROFILES_STORAGE_PATH + "\\" + phone number
 download_path = "D://driver"
 preferences = {"download.default_directory": download_path}
 chrome_options.add_experimental_option('prefs', preferences)
 chrome_options.to_capabilities()
 chrome_options.add_argument('--no-first-run --no-service-autorun --password-store=basic')
 chrome_options.add_argument('--disable-dev-shm-usage')
 chrome_options.add_argument('--profile-directory=Default')
 return uc.Chrome(options=chrome_options)

标签: pythonpython-3.xselenium-webdriverwebautomationundetected-chromedriver

解决方案


推荐阅读