diff --git a/java/src/org/openqa/selenium/grid/node/config/NodeOptions.java b/java/src/org/openqa/selenium/grid/node/config/NodeOptions.java index 19702f7dcd052..31ccdc9527ee5 100644 --- a/java/src/org/openqa/selenium/grid/node/config/NodeOptions.java +++ b/java/src/org/openqa/selenium/grid/node/config/NodeOptions.java @@ -351,7 +351,10 @@ private void addDriverConfigs( int toIndex = (i + 1) >= configIndexes.length ? drivers.size() : configIndexes[i + 1]; Map configMap = new HashMap<>(); drivers.subList(fromIndex, toIndex) - .forEach(keyValue -> configMap.put(keyValue.split("=")[0], keyValue.split("=")[1])); + .forEach(keyValue -> { + String [] values = keyValue.split("=", 2); + configMap.put(values[0], values[1]); + }); driversMap.add(configMap); } diff --git a/java/test/org/openqa/selenium/grid/node/config/NodeOptionsTest.java b/java/test/org/openqa/selenium/grid/node/config/NodeOptionsTest.java index a1b0263eeeedd..32ff26648b4ea 100644 --- a/java/test/org/openqa/selenium/grid/node/config/NodeOptionsTest.java +++ b/java/test/org/openqa/selenium/grid/node/config/NodeOptionsTest.java @@ -54,6 +54,8 @@ import static java.util.Collections.emptySet; import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.InstanceOfAssertFactories.LIST; +import static org.assertj.core.api.InstanceOfAssertFactories.MAP; import static org.junit.jupiter.api.Assertions.fail; import static org.junit.jupiter.api.Assumptions.assumeFalse; import static org.junit.jupiter.api.Assumptions.assumeTrue; @@ -366,6 +368,43 @@ void driversCanBeConfiguredWithASpecificWebDriverBinary() { geckoDriverLocation.equals(capabilities.getCapability("se:webDriverExecutable"))); } + @Test + void driversCanBeConfiguredWithASpecificArguments() { + String chLocation = "/Applications/Google Chrome Beta.app/Contents/MacOS/Google Chrome Beta"; + String chromeDriverLocation = "/path/to/chromedriver_beta/chromedriver"; + ChromeOptions chromeOptions = new ChromeOptions(); + chromeOptions.setBinary(chLocation); + chromeOptions.addArguments("--homepage=https://www.selenium.dev"); + + StringBuilder chromeCaps = new StringBuilder(); + new Json().newOutput(chromeCaps).setPrettyPrint(false).write(chromeOptions); + + String[] rawConfig = new String[]{ + "[node]", + "detect-drivers = false", + "[[node.driver-configuration]]", + "display-name = \"Chrome Beta\"", + String.format("webdriver-executable = '%s'", chromeDriverLocation), + String.format("stereotype = \"%s\"", chromeCaps.toString().replace("\"", "\\\"")) + }; + Config config = new TomlConfig(new StringReader(String.join("\n", rawConfig))); + + List reported = new ArrayList<>(); + new NodeOptions(config).getSessionFactories(capabilities -> { + reported.add(capabilities); + return Collections.singleton(HelperFactory.create(config, capabilities)); + }); + + assertThat(reported).is(supporting("chrome")); + assertThat(reported) + .filteredOn(capabilities -> capabilities.asMap().containsKey(ChromeOptions.CAPABILITY)); + + assertThat(reported.get(0).asMap()).asInstanceOf(MAP) + .extractingByKey(ChromeOptions.CAPABILITY).asInstanceOf(MAP) + .extractingByKey("args").asInstanceOf(LIST) + .containsExactly("--homepage=https://www.selenium.dev"); + } + @Test void driversConfigNeedsStereotypeField() { String[] rawConfig = new String[]{