|
54 | 54 | import static java.util.Collections.emptySet;
|
55 | 55 | import static java.util.Collections.singletonMap;
|
56 | 56 | import static org.assertj.core.api.Assertions.assertThat;
|
| 57 | +import static org.assertj.core.api.InstanceOfAssertFactories.LIST; |
| 58 | +import static org.assertj.core.api.InstanceOfAssertFactories.MAP; |
57 | 59 | import static org.junit.jupiter.api.Assertions.fail;
|
58 | 60 | import static org.junit.jupiter.api.Assumptions.assumeFalse;
|
59 | 61 | import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
@@ -366,6 +368,43 @@ void driversCanBeConfiguredWithASpecificWebDriverBinary() {
|
366 | 368 | geckoDriverLocation.equals(capabilities.getCapability("se:webDriverExecutable")));
|
367 | 369 | }
|
368 | 370 |
|
| 371 | + @Test |
| 372 | + void driversCanBeConfiguredWithASpecificArguments() { |
| 373 | + String chLocation = "/Applications/Google Chrome Beta.app/Contents/MacOS/Google Chrome Beta"; |
| 374 | + String chromeDriverLocation = "/path/to/chromedriver_beta/chromedriver"; |
| 375 | + ChromeOptions chromeOptions = new ChromeOptions(); |
| 376 | + chromeOptions.setBinary(chLocation); |
| 377 | + chromeOptions.addArguments("--homepage=https://www.selenium.dev"); |
| 378 | + |
| 379 | + StringBuilder chromeCaps = new StringBuilder(); |
| 380 | + new Json().newOutput(chromeCaps).setPrettyPrint(false).write(chromeOptions); |
| 381 | + |
| 382 | + String[] rawConfig = new String[]{ |
| 383 | + "[node]", |
| 384 | + "detect-drivers = false", |
| 385 | + "[[node.driver-configuration]]", |
| 386 | + "display-name = \"Chrome Beta\"", |
| 387 | + String.format("webdriver-executable = '%s'", chromeDriverLocation), |
| 388 | + String.format("stereotype = \"%s\"", chromeCaps.toString().replace("\"", "\\\"")) |
| 389 | + }; |
| 390 | + Config config = new TomlConfig(new StringReader(String.join("\n", rawConfig))); |
| 391 | + |
| 392 | + List<Capabilities> reported = new ArrayList<>(); |
| 393 | + new NodeOptions(config).getSessionFactories(capabilities -> { |
| 394 | + reported.add(capabilities); |
| 395 | + return Collections.singleton(HelperFactory.create(config, capabilities)); |
| 396 | + }); |
| 397 | + |
| 398 | + assertThat(reported).is(supporting("chrome")); |
| 399 | + assertThat(reported) |
| 400 | + .filteredOn(capabilities -> capabilities.asMap().containsKey(ChromeOptions.CAPABILITY)); |
| 401 | + |
| 402 | + assertThat(reported.get(0).asMap()).asInstanceOf(MAP) |
| 403 | + .extractingByKey(ChromeOptions.CAPABILITY).asInstanceOf(MAP) |
| 404 | + .extractingByKey("args").asInstanceOf(LIST) |
| 405 | + .containsExactly("--homepage=https://www.selenium.dev"); |
| 406 | + } |
| 407 | + |
369 | 408 | @Test
|
370 | 409 | void driversConfigNeedsStereotypeField() {
|
371 | 410 | String[] rawConfig = new String[]{
|
|
0 commit comments