Skip to content

[🐛 Bug]: ms:edgeOptions extensions invalid format - needs list but got object #15738

Open
@sebamomann

Description

@sebamomann

Description

I am currently running a Selenium Hub on Docker in OpenShift in version 4.32.0. For the Nodes I am using Windows 11 Agents, that connect with java using the jar obtained from https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.32.0/selenium-server-4.32.0.jar. The client configuration in form of a .toml looks like this.

[server]
registration-secret = "xxx"
host = "xxx"

[node]
detect-drivers = false
selenium-manager = true
max-sessions = 1
hub = "https://hub.intern:443"

[events]
publish = "tcp://hub.intern:4442"
subscribe = "tcp:/hub.intern:4443"

[[node.driver-configuration]]
display-name = "Firefox ESR"
stereotype = "{\"browserName\": \"firefox\", \"custom:computerName\": \"TEST1\"}"

[[node.driver-configuration]]
display-name = "Edge"
stereotype = "{\"browserName\": \"MicrosoftEdge\", \"custom:computerName\": \"TEST1\", \"ms:edgeOptions\": { \"args\": [\"--no-sandbox\"], \"extensions\": [] }}"

For the most part, basic tests etc everything works fine for firefox and edge. In one of our use cases we need to adapt the ms:edgeOptions to include another property, e.g. --use-fake-ui-for-media-stream. These additional options are passed in the java test as follows.

      EdgeOptions caps = new EdgeOptions();

      caps.setCapability("browserName", browserName);
      caps.setCapability("platformName", browserPlatform);
      caps.setCapability("custom:computerName", "TEST1");

      caps.addArguments("--no-sandbox", "--use-fake-ui-for-media-stream");
      caps.setExperimentalOption("extensions", Collections.emptyList());

      URL url = new URL(properties.getProperty("SELENIUM_URL"));

      ClientConfig config = ClientConfig.defaultConfig() //
              .readTimeout(Duration.ofMinutes(5)) //
              .connectionTimeout(Duration.ofMinutes(10)) //
              .baseUrl(url);

      HttpCommandExecutor commandExecutor = new HttpCommandExecutor(config);
      driver = new RemoteWebDriver(commandExecutor, caps);

or

      DesiredCapabilities caps = new DesiredCapabilities();

      caps.setCapability("browserName", browserName);
      caps.setCapability("platformName", browserPlatform);
      caps.setCapability("custom:computerName", "TEST1");


      EdgeOptions opts = new EdgeOptions();
      opts.addArguments("--no-sandbox", "--use-fake-ui-for-media-stream");
      opts.setExperimentalOption("extensions", Collections.emptyList());

      caps.setCapability("ms:edgeOptions", opts);

      URL url = new URL(properties.getProperty("SELENIUM_URL"));

      ClientConfig config = ClientConfig.defaultConfig() //
              .readTimeout(Duration.ofMinutes(5)) //
              .connectionTimeout(Duration.ofMinutes(10)) //
              .baseUrl(url);

      HttpCommandExecutor commandExecutor = new HttpCommandExecutor(config);
      driver = new RemoteWebDriver(commandExecutor, caps);

When executing the test, the capabilities are correctly displayed as

Capabilities {browserName: MicrosoftEdge, ms:edgeOptions: {args: [--no-sandbox, --use-fake-ui-for-media-stream], extensions: []}, platformName: Windows 11, custom:computerName: TEST1}

However, I do get the error that class java.util.LinkedHashMap cannot be cast to class java.util.List. Looking into the log of the node i can see that the extensions attribute is somehow converted into an object {}

17:53:28.088 WARN [SeleniumSpanExporter$1.lambda$export$3] - {"traceId": "xxx","eventTime": 1747151608087457100,"eventName": "Unable to create session with the driver","attributes": {"current.session.count": 0,"logger": "org.openqa.selenium.grid.node.local.LocalNode","session.request.capabilities": "Capabilities {browserName: MicrosoftEdge, ms:edgeOptions: {args: [--no-sandbox, --use-fake-ui-for-media-stream], extensions: {}}, platformName: Windows 11, custom:computerName: TEST1, "session.request.downstreamdialect": "[W3C]"}}

I also tried converting the node TOML into a JSON, with little to no success, the result stays the same, with a partly different error message. The JSON looks as follows.

{
  "registrationSecret": "xxx",
  "server": {
    "host":               "xxx,
    "port":               5555
  },
  "registrar": {
    "hubUri": "https://hub.intern:443"
  },
  "role":    "node",
  "register":  true,
  "maxSessions":      1,
  "detectDrivers": false,
  "seleniumManager": true,
  "events": {
    "publish":   "tcp://hub.intern:4442",
    "subscribe": "tcp://hub.intern:4443"
  },
  "capabilities": [
    {
      "browserName":       "MicrosoftEdge",
      "platformName":      "Windows 11",
      "maxInstances":      1,
      "custom:computerName": "TEST1",
      "ms:edgeOptions": {
        "args":       ["--no-sandbox"],
        "extensions": []
      } 
    }
  ]
}

The problem i have here is that the registrationSecret, as well as the detectDrivers and seleniumManager do not work inside the JSON, seemingly no matter where I put them. When I pass them as options to the node start command, they work.

The other, similar error I encountered is Could not start a new session. Response code 400. Message: invalid argument: entry 0 of 'firstMatch' is invalid\nfrom invalid argument: cannot parse capability: ms:edgeOptions\nfrom invalid argument: cannot parse extensions\nfrom invalid argument: must be a list

The node itself registers correctly. For Edge:

Adding Edge for {"browserName": "MicrosoftEdge","ms:edgeOptions": {"args": ["--no-sandbox"],"extensions": []},"platformName": "Windows 11","custom:computerName": "TEST1"} 1 times

The status endpoint returns the expected JSON.

{
  "value": {
    "ready": true,
    "message": "Ready",
    "registered": true,
    "node": {
      "availability": "UP",
      "externalUri": "xxx",
      "heartbeatPeriod": 60000,
      "maxSessions": 1,
      "nodeId": "xxx",
      "osInfo": {
        "arch": "amd64",
        "name": "Windows 11",
        "version": "10.0"
      },
      "sessionTimeout": 300000,
      "slots": [
        {
          "id": {
            "hostId": "xxx",
            "id": "xxx"
          },
          "lastStarted": "1970-01-01T00:00:00Z",
          "session": null,
          "stereotype": {
            "browserName": "firefox",
            "platformName": "Windows 11",
            "custom:computerName": "TEST1"
          }
        },
        {
          "id": {
            "hostId": "xxx",
            "id": "xxx"
          },
          "lastStarted": "1970-01-01T00:00:00Z",
          "session": null,
          "stereotype": {
            "browserName": "MicrosoftEdge",
            "ms:edgeOptions": {
              "args": [
                "--no-sandbox"
              ],
              "extensions": [
              ],
              "binary": "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"
            },
            "platformName": "Windows 11",
            "custom:computerName": "TEST1"
          }
        }
      ],
      "version": "4.32.0 (revision d17c8aa950)"
    }
  }
}

The Nodes are Windows11, the Java test is run from Mac 15.4.1.

Reproducible Code

EdgeOptions caps = new EdgeOptions();

caps.setCapability("browserName", browserName);
caps.setCapability("platformName", browserPlatform);
caps.setCapability("custom:computerName", "TEST1");

caps.addArguments("--no-sandbox", "--use-fake-ui-for-media-stream");
caps.setExperimentalOption("extensions", Collections.emptyList());

URL url = new URL(properties.getProperty("SELENIUM_URL"));

ClientConfig config = ClientConfig.defaultConfig() //
              .readTimeout(Duration.ofMinutes(5)) //
              .connectionTimeout(Duration.ofMinutes(10)) //
              .baseUrl(url);

HttpCommandExecutor commandExecutor = new HttpCommandExecutor(config);
driver = new RemoteWebDriver(commandExecutor, caps);

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!B-gridEverything grid and server relatedC-javaJava BindingsD-edgeI-defectSomething is not working as intendedOS-windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions