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

如何在Chrome无头模式下运行Botium-cli及Botium-Webdriver-Connector?

嘿,我刚搞定了这个问题,正好可以分享给你!

因为目标网页在PhantomJS里跑不起来,我改用Chrome无头模式来运行Botium-CLI和Botium-Webdriver-Connector了。之前Florian给的方案是可行的,不过我是在Ubuntu系统的Jenkins上部署的,还得额外加两个参数才能正常跑,最终的配置是这样的:

"WEBDRIVERIO_OPTIONS": {
  "desiredCapabilities": {
    "browserName": "chrome",
    "chromeOptions": {
      "args": [
        "--headless",
        "--no-sandbox",
        "--disable-dev-shm-usage"
      ]
    }
  }
}

顺便解释下这几个关键参数的作用:

  • --headless:启用Chrome无头模式,无需可视化界面即可运行浏览器
  • --no-sandbox:关闭Chrome沙箱机制,Jenkins通常以非root用户运行,沙箱会导致浏览器启动失败,所以必须添加该参数
  • --disable-dev-shm-usage:禁用Chrome对/dev/shm临时文件系统的使用,避免Ubuntu环境下因该分区空间不足导致浏览器崩溃

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.12 03:49:46