【问题标题】:Chrome profile not loading with seleniumChrome 配置文件未加载硒
【发布时间】:2020-12-04 05:31:31
【问题描述】:

这是我的代码:

from selenium import webdriver

options = webdriver.ChromeOptions() 
options.add_argument(r"user-data-dir=C:\Users\shahr\AppData\Local\Google\Chrome\User Data\Profile 1") #Path to your chrome profile
w = webdriver.Chrome(executable_path=r"C:\Program Files (x86)\chromedriver.exe", options=options)

我从其他 StackOverFlow Answers 中尝试过,但它拒绝打开所需的配置文件

【问题讨论】:

  • 尝试删除 options.argument。
  • @bonifacio_kid 你是什么意思

标签: python selenium


【解决方案1】:
chrom_options.add_argument("user-data-dir=C:\\Users\robert.car\\AppData\\Local\\Google\\Chrome\\User Data")

chrom_options.add_argument("profile-directory=Profile 1")

user-data-dir 将 profile 视为默认值,您不必指定它。如果是其他东西,则通过 profile-directory 参数指定它

创建个人资料的步骤:

打开:地址栏中的 chrome://version

复制用户目录文件夹完全到例如c:\tmp\newdir

打开复制的用户数据 (newdir) 并搜索名为 Default 的文件夹。这是配置文件文件夹。

重命名默认文件夹为“配置文件 1”

现在使用这个:

chrom_options.add_argument("user-data-dir=c:\\tmp\\newdir")

chrom_options.add_argument("profile-directory=Profile 1")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-01
    • 2023-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多