|
23 | 23 | import org.openqa.selenium.ImmutableCapabilities; |
24 | 24 | import org.openqa.selenium.Platform; |
25 | 25 | import org.openqa.selenium.SessionNotCreatedException; |
| 26 | +import org.openqa.selenium.WebDriver; |
26 | 27 | import org.openqa.selenium.chrome.ChromeOptions; |
27 | 28 | import org.openqa.selenium.firefox.FirefoxOptions; |
28 | 29 | import org.openqa.selenium.ie.InternetExplorerOptions; |
@@ -351,10 +352,36 @@ public void commandsShouldBeSentWithW3CHeaders() { |
351 | 352 |
|
352 | 353 | @Test |
353 | 354 | public void shouldUseWebDriverInfoToFindAMatchingDriverImplementationForRequestedCapabilitiesIfRemoteUrlNotSet() { |
| 355 | + WebDriver driver = RemoteWebDriver.builder() |
| 356 | + .oneOf(new ImmutableCapabilities("browser", "selenium-test")) |
| 357 | + .connectingWith(config -> req -> CANNED_SESSION_RESPONSE) |
| 358 | + .build(); |
| 359 | + |
| 360 | + assertThat(driver).isInstanceOf(FakeWebDriverInfo.FakeWebDriver.class); |
354 | 361 | } |
355 | 362 |
|
356 | 363 | @Test |
357 | 364 | public void shouldAugmentDriverIfPossible() { |
| 365 | + HttpResponse response = new HttpResponse() |
| 366 | + .setContent(Contents.asJson(ImmutableMap.of( |
| 367 | + "value", ImmutableMap.of( |
| 368 | + "sessionId", SESSION_ID, |
| 369 | + "capabilities", new ImmutableCapabilities("firefox", "caps"))))); |
| 370 | + |
| 371 | + Augmenter augmenter = new Augmenter().addDriverAugmentation("firefox", |
| 372 | + AugmenterTest.HasMagicNumbers.class, |
| 373 | + (c, exe) -> () -> 1); |
| 374 | + WebDriver driver = RemoteWebDriver.builder() |
| 375 | + .oneOf(new FirefoxOptions()) |
| 376 | + .augmentUsing(augmenter) |
| 377 | + .address("http://localhost:34576") |
| 378 | + .connectingWith(config -> req -> response) |
| 379 | + .build(); |
| 380 | + |
| 381 | + int number = ((AugmenterTest.HasMagicNumbers)driver).getMagicNumber(); |
| 382 | + |
| 383 | + assertThat(driver).isInstanceOf(AugmenterTest.HasMagicNumbers.class); |
| 384 | + assertThat(number).isEqualTo(1); |
358 | 385 | } |
359 | 386 |
|
360 | 387 | @SuppressWarnings("unchecked") |
|
0 commit comments