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

Chrome 127版本下Seleniumbase如何禁用搜索引擎选择弹窗?

解决Chrome 127搜索引擎选择弹窗的Seleniumbase方案

在Seleniumbase里添加Chrome启动参数有三种常用方式,都能实现禁用搜索引擎选择弹窗的效果:

1. 在BaseCase测试类中添加参数

如果你的测试是基于Seleniumbase的BaseCase类编写的,直接在setUp()方法里用self.add_argument()添加参数即可:

from seleniumbase import BaseCase

class MyAutomationTest(BaseCase):
    def setUp(self):
        super().setUp()
        # 禁用Chrome的搜索引擎选择弹窗
        self.add_argument("--disable-search-engine-choice-screen")

    def test_my_flow(self):
        self.open("https://your-target-url.com")
        # 这里写你的自动化逻辑

2. 自定义ChromeOptions初始化Driver

如果是直接初始化Driver实例,可以先创建ChromeOptions对象并添加参数,再传给Driver:

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

# 创建Chrome配置对象并添加参数
chrome_options = Options()
chrome_options.add_argument("--disable-search-engine-choice-screen")

# 传入自定义配置初始化Driver
driver = Driver(chrome_options=chrome_options)
driver.open("https://your-target-url.com")
# 执行自动化操作...
driver.quit()

3. 命令行运行时指定参数

如果是通过pytest命令行运行测试脚本,可以直接在命令里追加Chrome启动参数:

pytest your_test_script.py --chrome-args="--disable-search-engine-choice-screen"

以上三种方式任选其一,都能让Chrome启动时跳过搜索引擎选择弹窗,确保自动化流程正常执行。

内容的提问来源于stack exchange,提问作者tromotixc

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.20 12:33:11