You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用Python版Selenium以正常模式启动Firefox浏览器?

解决Selenium启动Firefox进入测试模式的问题

Selenium默认会创建临时Firefox配置文件并启用测试相关参数,导致浏览器显示“测试模式”。以下两种方法可以启动正常模式:

方法一:使用Firefox默认用户配置文件

直接调用你日常使用的Firefox配置文件,会加载书签、插件等个人设置:

  1. 找到你的Firefox配置文件路径:

    • Windows:%APPDATA%\Mozilla\Firefox\Profiles\xxxxx.default-release
    • macOS:~/Library/Application Support/Firefox/Profiles/xxxx.default-release
    • Linux:~/.mozilla/firefox/xxxx.default-release
  2. 修改代码指定配置文件:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

options = Options()
# 替换为你的实际配置文件路径
options.add_argument("-profile")
options.add_argument("C:/Users/你的用户名/AppData/Roaming/Mozilla/Firefox/Profiles/xxxxxx.default-release")

driver = webdriver.Firefox(options=options)
driver.get("http://github.com")

方法二:禁用测试模式标识

使用临时配置但关闭自动化测试相关的提示和标识,适合不需要个人配置的场景:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

options = Options()
# 禁用WebDriver检测
options.set_preference("dom.webdriver.enabled", False)
options.set_preference("useAutomationExtension", False)
# 关闭测试模式横幅
options.add_argument("--disable-blink-features=AutomationControlled")

driver = webdriver.Firefox(options=options)
driver.get("http://github.com")

内容的提问来源于stack exchange,提问作者Adem Dişbudak

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 04:01:07