|
79 | 79 |
|
80 | 80 | public class FirefoxDriverTest extends JupiterTestBase { |
81 | 81 |
|
82 | | - private static final String EXT_PATH = "common/extensions/webextensions-selenium-example.xpi"; |
83 | | - private static final String EXT_PATH_DIR = "common/extensions/webextensions-selenium-example"; |
| 82 | + private static final String EXT_XPI = "common/extensions/webextensions-selenium-example.xpi"; |
| 83 | + private static final String EXT_SIGNED_ZIP = "common/extensions/webextensions-selenium-example.zip"; |
| 84 | + private static final String EXT_UNSIGNED_ZIP = "common/extensions/webextensions-selenium-example-unsigned.zip"; |
| 85 | + private static final String EXT_SIGNED_DIR = "common/extensions/webextensions-selenium-example-signed"; |
| 86 | + private static final String EXT_UNSIGNED_DIR = "common/extensions/webextensions-selenium-example"; |
84 | 87 | private static char[] CHARS = |
85 | 88 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!\"§$%&/()+*~#',.-_:;\\" |
86 | 89 | .toCharArray(); |
@@ -544,45 +547,88 @@ public void testFirefoxCanNativelyClickOverlappingElements() { |
544 | 547 | } |
545 | 548 |
|
546 | 549 | @Test |
547 | | - public void canAddRemoveExtensions() { |
548 | | - Path extension = InProject.locate(EXT_PATH); |
| 550 | + public void canAddRemoveXpiExtensions() { |
| 551 | + Path extension = InProject.locate(EXT_XPI); |
549 | 552 |
|
550 | 553 | String id = ((HasExtensions) driver).installExtension(extension); |
551 | 554 | assertThat( id). isEqualTo( "[email protected]"); |
552 | 555 |
|
553 | | - try { |
554 | | - ((HasExtensions) driver).uninstallExtension(id); |
555 | | - } catch (WebDriverException ex) { |
556 | | - fail(ex.getMessage()); |
557 | | - } |
| 556 | + driver.get(pages.blankPage); |
| 557 | + WebElement injected = driver.findElement(By.id("webextensions-selenium-example")); |
| 558 | + assertThat(injected.getText()).isEqualTo("Content injected by webextensions-selenium-example"); |
| 559 | + |
| 560 | + ((HasExtensions) driver).uninstallExtension(id); |
| 561 | + |
| 562 | + driver.navigate().refresh(); |
| 563 | + assertThat(driver.findElements(By.id("webextensions-selenium-example")).size()).isZero(); |
558 | 564 | } |
559 | 565 |
|
560 | 566 | @Test |
561 | | - public void canAddRemoveTempExtensions() { |
562 | | - Path extension = InProject.locate(EXT_PATH); |
| 567 | + public void canAddRemoveZipUnSignedExtensions() { |
| 568 | + Path extension = InProject.locate(EXT_UNSIGNED_ZIP); |
563 | 569 |
|
564 | 570 | String id = ((HasExtensions) driver).installExtension(extension, true); |
565 | 571 | assertThat( id). isEqualTo( "[email protected]"); |
566 | 572 |
|
567 | | - try { |
568 | | - ((HasExtensions) driver).uninstallExtension(id); |
569 | | - } catch (WebDriverException ex) { |
570 | | - fail(ex.getMessage()); |
571 | | - } |
| 573 | + driver.get(pages.blankPage); |
| 574 | + WebElement injected = driver.findElement(By.id("webextensions-selenium-example")); |
| 575 | + assertThat(injected.getText()).isEqualTo("Content injected by webextensions-selenium-example"); |
| 576 | + |
| 577 | + ((HasExtensions) driver).uninstallExtension(id); |
| 578 | + |
| 579 | + driver.navigate().refresh(); |
| 580 | + assertThat(driver.findElements(By.id("webextensions-selenium-example")).size()).isZero(); |
| 581 | + } |
| 582 | + |
| 583 | + @Test |
| 584 | + public void canAddRemoveZipSignedExtensions() { |
| 585 | + Path extension = InProject.locate(EXT_SIGNED_ZIP); |
| 586 | + |
| 587 | + String id = ((HasExtensions) driver).installExtension(extension); |
| 588 | + assertThat( id). isEqualTo( "[email protected]"); |
| 589 | + |
| 590 | + driver.get(pages.blankPage); |
| 591 | + WebElement injected = driver.findElement(By.id("webextensions-selenium-example")); |
| 592 | + assertThat(injected.getText()).isEqualTo("Content injected by webextensions-selenium-example"); |
| 593 | + |
| 594 | + ((HasExtensions) driver).uninstallExtension(id); |
| 595 | + |
| 596 | + driver.navigate().refresh(); |
| 597 | + assertThat(driver.findElements(By.id("webextensions-selenium-example")).size()).isZero(); |
572 | 598 | } |
573 | 599 |
|
574 | 600 | @Test |
575 | | - public void canAddRemoveTempExtensionsDirectory() { |
576 | | - Path extension = InProject.locate(EXT_PATH_DIR); |
| 601 | + public void canAddRemoveUnsignedExtensionsDirectory() { |
| 602 | + Path extension = InProject.locate(EXT_UNSIGNED_DIR); |
577 | 603 |
|
578 | 604 | String id = ((HasExtensions) driver).installExtension(extension, true); |
579 | 605 | assertThat( id). isEqualTo( "[email protected]"); |
580 | 606 |
|
581 | | - try { |
582 | | - ((HasExtensions) driver).uninstallExtension(id); |
583 | | - } catch (WebDriverException ex) { |
584 | | - fail(ex.getMessage()); |
585 | | - } |
| 607 | + driver.get(pages.blankPage); |
| 608 | + WebElement injected = driver.findElement(By.id("webextensions-selenium-example")); |
| 609 | + assertThat(injected.getText()).isEqualTo("Content injected by webextensions-selenium-example"); |
| 610 | + |
| 611 | + ((HasExtensions) driver).uninstallExtension(id); |
| 612 | + |
| 613 | + driver.navigate().refresh(); |
| 614 | + assertThat(driver.findElements(By.id("webextensions-selenium-example")).size()).isZero(); |
| 615 | + } |
| 616 | + |
| 617 | + @Test |
| 618 | + public void canAddRemoveSignedExtensionsDirectory() { |
| 619 | + Path extension = InProject.locate(EXT_SIGNED_DIR); |
| 620 | + |
| 621 | + String id = ((HasExtensions) driver).installExtension(extension); |
| 622 | + assertThat( id). isEqualTo( "[email protected]"); |
| 623 | + |
| 624 | + driver.get(pages.blankPage); |
| 625 | + WebElement injected = driver.findElement(By.id("webextensions-selenium-example")); |
| 626 | + assertThat(injected.getText()).isEqualTo("Content injected by webextensions-selenium-example"); |
| 627 | + |
| 628 | + ((HasExtensions) driver).uninstallExtension(id); |
| 629 | + |
| 630 | + driver.navigate().refresh(); |
| 631 | + assertThat(driver.findElements(By.id("webextensions-selenium-example")).size()).isZero(); |
586 | 632 | } |
587 | 633 |
|
588 | 634 | @Test |
|
0 commit comments