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

Selenium 4.5 Grid节点搭配Firefox/GeckoDriver运行异常求助

解决Selenium Grid 4.5 + WebdriverIO + Firefox的--remote-debugging-port参数错误

问题根源

这个错误是因为WebdriverIO默认会为所有浏览器自动添加remote-debugging-port参数,但该参数是Chrome专属的,Firefox并不支持通过capabilities设置它。

解决方案

1. 修正WebdriverIO的Capabilities配置

在wdio.conf.ts中,为Firefox配置明确禁用调试端口的自动添加,并指定Firefox Nightly二进制路径:

capabilities: [{
    browserName: 'firefox',
    'moz:firefoxOptions': {
        binary: '/Applications/Firefox.app/Contents/MacOS/firefox-nightly',
        // 明确告诉Firefox不要启用远程调试端口
        args: ['--no-remote-debugging-port']
    },
    // 禁用WebdriverIO自动添加的devtools端口配置
    'wdio:devtoolsOptions': {
        port: null
    }
}]

2. 调整Selenium Grid节点的TOML配置

简化节点配置,避免转义错误,确保stereotype只包含必要的Firefox参数:

[node]
detect-drivers = false
[[node.driver-configuration]]
max-sessions = 1
display-name = "Firefox"
stereotype = '{"browserName": "firefox", "browserVersion": "105.0.1", "platformName": "MAC", "moz:firefoxOptions": {"binary": "/Applications/Firefox.app/Contents/MacOS/firefox-nightly"}}'
webdriver-executable = '/usr/local/bin/geckodriver'

注意:用单引号包裹stereotype内容,避免双引号的转义问题,同时不需要在节点配置中额外添加调试相关参数。

3. 确保依赖版本兼容

  • 确认geckodriver版本与Firefox Nightly 105.0.1兼容(推荐使用geckodriver 0.31.0版本)
  • 无需安装Puppeteer,Selenium Grid通过geckodriver直接驱动Firefox

4. 启动Selenium节点的正确命令

使用配置文件启动Firefox节点:

java -jar selenium-server-4.5.0.jar node --config node-firefox.toml

验证

启动Hub和节点后,运行WebdriverIO测试,应该不再出现--remote-debugging-port相关的400错误。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.18 01:45:35