如何使 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 https://stackoverflow.com/questions/62741852/why-isnt-the-chromedriver-executable-in-the-path-even-after-using-chromedrive/62742262#62742262 and 自定义 Chrome 用户个人资料 https://stackoverflow.com/questions/49270109/how-to-open-a-chrome-profile-through-python/49280195#49280195同时使用以下解决方案:
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/')
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)