【问题标题】:How to use default browser profile in Selenium instead of new one? [duplicate]如何在 Selenium 中使用默认浏览器配置文件而不是新的? [复制]
【发布时间】:2019-10-07 16:16:47
【问题描述】:

我找不到任何相关的答案,我的问题很直接。

上下文并不真正相关。

Selenium 使用我通常安装的浏览器(Chrome 或 Firefox)对我来说非常重要,在进行编码时。

【问题讨论】:

  • chromedriver 默认使用您的“正常安装的浏览器”。这就是为什么 chromedriver 和 chrome 版本必须正确的原因。 “普通浏览器”而不是“新实例”是什么意思?您不希望 Selenium 每次运行时都启动一个新浏览器吗?
  • 您不能使用默认配置文件,但您可以复制它并设置驱动程序选项以在启动时使用该配置文件。
  • 检查this

标签: selenium google-chrome


【解决方案1】:

也许使用您的标准配置文件有帮助?在我的情况下,网站正在检测 Selenium 浏览器。这段代码解决了我的问题。

path = str(Path.home())
path = path + "/.mozilla/firefox/xxxx.default-release"
profile = FirefoxProfile(path)
driver = webdriver.Firefox(profile)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-10
    • 2013-08-30
    • 2023-01-31
    • 2021-03-12
    • 1970-01-01
    相关资源
    最近更新 更多