|
30 | 30 | import org.openqa.selenium.ParallelTestRunner.Worker;
|
31 | 31 | import org.openqa.selenium.WebDriver;
|
32 | 32 | import org.openqa.selenium.WebElement;
|
| 33 | +import org.openqa.selenium.build.InProject; |
| 34 | +import org.openqa.selenium.remote.Augmenter; |
33 | 35 | import org.openqa.selenium.remote.CapabilityType;
|
34 | 36 | import org.openqa.selenium.remote.Command;
|
35 | 37 | import org.openqa.selenium.remote.CommandExecutor;
|
36 | 38 | import org.openqa.selenium.remote.DriverCommand;
|
37 | 39 | import org.openqa.selenium.remote.RemoteWebDriver;
|
38 |
| -import org.openqa.selenium.remote.RemoteWebDriverBuilder; |
39 | 40 | import org.openqa.selenium.remote.SessionId;
|
40 | 41 | import org.openqa.selenium.remote.UnreachableBrowserException;
|
41 | 42 | import org.openqa.selenium.support.ui.ExpectedCondition;
|
|
51 | 52 | import java.io.File;
|
52 | 53 | import java.io.IOException;
|
53 | 54 | import java.lang.reflect.Field;
|
| 55 | +import java.net.MalformedURLException; |
| 56 | +import java.net.URL; |
| 57 | +import java.nio.file.Path; |
54 | 58 | import java.time.Duration;
|
55 | 59 | import java.util.ArrayList;
|
56 | 60 | import java.util.List;
|
@@ -521,20 +525,42 @@ public void testFirefoxCanNativelyClickOverlappingElements() {
|
521 | 525 | }
|
522 | 526 |
|
523 | 527 | @Test
|
524 |
| - public void shouldAllowRemoteWebDriversToBeAugmentedWithHasExtensions() { |
| 528 | + public void shouldAddExtensions() { |
| 529 | + Path extension = InProject.locate("third_party/firebug/favourite_colour-1.1-an+fx.xpi"); |
| 530 | + |
| 531 | + ((FirefoxDriver) driver).installExtension(extension); |
| 532 | + ((FirefoxDriver) driver).uninstallExtension("favourite-colour-examples@mozilla.org"); |
| 533 | + } |
| 534 | + |
| 535 | + @Test |
| 536 | + public void shouldAllowRemoteWebDriverBuilderToUseHasExtensions() { |
525 | 537 | WebDriver driver = RemoteWebDriver.builder()
|
526 | 538 | .oneOf(new FirefoxOptions())
|
527 | 539 | .address("http://localhost:4444/")
|
528 | 540 | .build();
|
529 | 541 |
|
530 | 542 | try {
|
531 |
| - assertThat(driver).isInstanceOf(HasExtensions.class); |
532 |
| - fail(driver.getClass().getName()); |
| 543 | + Path extension = InProject.locate("third_party/firebug/favourite_colour-1.1-an+fx.xpi"); |
| 544 | + ((HasExtensions) driver).installExtension(extension); |
| 545 | + ((HasExtensions) driver).uninstallExtension("favourite-colour-examples@mozilla.org"); |
533 | 546 | } finally {
|
534 | 547 | driver.quit();
|
535 | 548 | }
|
536 | 549 | }
|
537 | 550 |
|
| 551 | + @Test |
| 552 | + public void shouldAllowDriverToBeAugmentedWithHasExtensions() throws MalformedURLException { |
| 553 | + WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/"), new FirefoxOptions()); |
| 554 | + WebDriver augmentedDriver = new Augmenter().augment(driver); |
| 555 | + |
| 556 | + try { |
| 557 | + Path extension = InProject.locate("third_party/firebug/favourite_colour-1.1-an+fx.xpi"); |
| 558 | + ((HasExtensions) augmentedDriver).installExtension(extension); |
| 559 | + ((HasExtensions) augmentedDriver).uninstallExtension("favourite-colour-examples@mozilla.org"); |
| 560 | + } finally { |
| 561 | + driver.quit(); |
| 562 | + } |
| 563 | + } |
538 | 564 |
|
539 | 565 | private static class CustomFirefoxProfile extends FirefoxProfile {}
|
540 | 566 |
|
|
0 commit comments