我在另一篇文章中看到了这种实现选项的方法..但它仍然不工作.
尝试打开默认用户配置文件,而不是未登录的chrome选项卡。
k5hmc34c1#
这不是正确的方法,你必须添加两个参数:user-data-dir和profile-directory。此外,最好使用service而不是executable_path,因为它已被弃用。
user-data-dir
profile-directory
service
executable_path
from selenium import webdriver from selenium.webdriver.chrome.service import Service options = webdriver.ChromeOptions() options.add_argument("user-data-dir=C:\\Users\\pc1\\AppData\\Local\\Google\\Chrome\\User Data") options.add_argument("profile-directory=Profile 1") chromedriver_path = '...' driver = webdriver.Chrome(service=Service(chromedriver_path), options=options)
1条答案
按热度按时间k5hmc34c1#
这不是正确的方法,你必须添加两个参数:
user-data-dir
和profile-directory
。此外,最好使用service
而不是executable_path
,因为它已被弃用。