Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sebamomann opened this issue May 13, 2025 · 1 comment
Labels
A-needs-triaging A Selenium member will evaluate this soon! B-grid Everything grid and server related C-java Java Bindings D-edge I-defect Something is not working as intended OS-windows

Comments

@sebamomann
Copy link

sebamomann commented May 13, 2025

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);
@sebamomann sebamomann added I-defect Something is not working as intended A-needs-triaging A Selenium member will evaluate this soon! labels May 13, 2025
@selenium-ci
Copy link
Member

@sebamomann, thank you for creating this issue. We will troubleshoot it as soon as we can.

Selenium Triage Team: remember to follow the Triage Guide

@github-actions github-actions bot added B-grid Everything grid and server related C-java Java Bindings D-edge OS-windows labels May 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-needs-triaging A Selenium member will evaluate this soon! B-grid Everything grid and server related C-java Java Bindings D-edge I-defect Something is not working as intended OS-windows
Projects
None yet
Development

No branches or pull requests

2 participants