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

在Selenoid中运行Selenide测试时出现enableVNC W3C Capabilities错误求助

基于Selenoid运行Selenide测试时出现IllegalArgumentException错误

错误信息

Caused by: java.lang.IllegalArgumentException: Illegal key values seen in w3c capabilities: [enableVNC]

Docker Compose配置

version: '3.8'

services:
  selenoid:
    image: aerokube/selenoid:latest-release
    container_name: selenoid
    network_mode: bridge
    ports:
      - "4444:4444"
    volumes:
      - ".:/etc/selenoid"
      - "/var/run/docker.sock:/var/run/docker.sock"
    command: ["-limit=4", "-capture-driver-logs", "-max-timeout=0h5m0s"]

  selenoid-ui:
    image: aerokube/selenoid-ui:latest-release
    container_name: selenoid-ui
    network_mode: bridge
    ports:
      - "8080:8080"
    links:
      - selenoid
    depends_on:
      - selenoid
    command: [ "--selenoid-uri", "http://selenoid:4444" ]

  chrome113:
    image: selenoid/vnc_chrome:113.0

原浏览器配置代码

import static com.codeborne.selenide.Configuration.*;

browser = CHROME;
browserVersion = "113.0";
browserSize = "1920x1080";
capabilities.setCapability("enableVNC", true);
browserCapabilities = capabilities;

配置文件:

selenide.remote=http://localhost:4444/wd/hub

问题原因

enableVNC是Selenoid专属的扩展配置项,不属于W3C标准的浏览器能力范畴,直接放在顶层capabilities中会触发W3C能力校验失败,从而抛出错误。这类Selenoid特定配置需要统一放在selenoid:options命名空间下。

修正后的代码

ChromeOptions options = new ChromeOptions();
options.setCapability("browserVersion", "113.0");
options.setCapability("selenoid:options", new HashMap<String, Object>() {{
    /* 添加测试标识 */
    put("name", scenario.getName());
    /* 开启视频录制 */
    put("enableVideo", true);
    /* 开启VNC */
    put("enableVNC", true);
    /* 设置视频文件名 */
    put("videoName", scenario.getName());
}});
browserCapabilities = options;

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.18 13:22:21