【问题标题】:How to use predefined chrome profile in selenium for python?如何在 selenium 中为 python 使用预定义的 chrome 配置文件?
【发布时间】:2017-12-20 08:27:58
【问题描述】:

我的 chrome 浏览器中有几个自定义配置文件。例如,我想在我的 selenium 中使用“test 2”配置文件。 (见下图)

https://i.stack.imgur.com/iYcG8.png

这是我从网上看到的代码。

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = webdriver.ChromeOptions()
options.add_argument(r'user-data-dir=C:\Users\mycomputer\AppData\Local\Google\Chrome\User Data')
browser = webdriver.Chrome(executable_path=r"C:\Users\mycomputer\AppData\Local\Programs\Python\Python36-32\chromedriver.exe", chrome_options=options)

如何使用“测试 2”配置文件?谢谢。

【问题讨论】:

    标签: python python-3.x selenium selenium-chromedriver


    【解决方案1】:

    你只需要再添加一个参数:

    options.add_argument('--profile-directory=Profile 1')
    

    Profile 1 - 是您个人资料的目录,其名称与个人资料名称不同。您可以在user-data-dir 中浏览所有配置文件目录。如何找出“test 2”配置文件的目录是什么目录 - 你可以在这里找到https://superuser.com/a/723145

    【讨论】:

      猜你喜欢
      • 2019-02-22
      • 1970-01-01
      • 2021-05-15
      • 2018-09-02
      • 2016-11-26
      • 2015-09-12
      • 2019-05-27
      • 1970-01-01
      相关资源
      最近更新 更多