python - python webdriver_manager chrome 自定义配置文件
问题描述
如何使 webdriver_manager.chrome 使用自定义 chrome 用户配置文件?
我知道对于 selenium webdriver,我可以这样指定:
options = Options()
options.add_argument(f'user-data-dir={script_path}\\User Data\\profile')
driver = webdriver.Chrome(executable_path=f'{script_path}\\chromedriver.exe', options=options)
但是因为我想让 chromedriver 自己安装正确的版本(因为我把我的程序卖给了非 python 用户)我正在使用 webdriver_manager 模块,它看起来像这样:
driver = webdriver.Chrome(ChromeDriverManager().install())
有什么方法可以加载自定义配置文件,以便在使用 webdriver_manager 时将我在网站上的登录数据保存在我的配置文件中?
解决方案
您可以使用以下解决方案同时使用webdriver_manager.chrome和自定义 chrome 用户配置文件:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
options = Options()
options.add_argument(f'user-data-dir={script_path}\\User Data\\profile')
driver = webdriver.Chrome(executable_path=ChromeDriverManager().install(), options=options)
driver.get('https://www.google.com/')
推荐阅读
- python - 如何在 Python 中创建动态嵌套字典
- python-3.x - 通过 pysimplegui 将变量传递给 pyperclip
- next.js - 如何使用模块联合将 i18n 实现到微前端应用程序中
- reactjs - 当我尝试使用 useEffect() 自动化时反应滑块问题
- r - 在 R 中提取/读取文件时使用逗号
- python - UserWarning: MongoClient 在 fork 之前打开。仅在 fork 后创建 MongoClient
- python - ValueError:None 中并非所有运算符都支持稀疏矩阵。稀疏矩阵请使用“TPOT sparse”
- python - Python:- 从包含在标签中的行 [0] 中提取列标题。去掉行星名称后的unicode符号和链接号
- php - 我需要使用 Laravel 项目的所有附加功能吗?
- amazon-web-services - 如何配置 MediaConvert 为不同的输入触发不同的事件?