-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[java] add tests for Firefox HasExtensions functionality
- Loading branch information
1 parent
15dfc62
commit f767022
Showing
3 changed files
with
33 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,12 +30,13 @@ | |
import org.openqa.selenium.ParallelTestRunner.Worker; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.build.InProject; | ||
import org.openqa.selenium.remote.Augmenter; | ||
import org.openqa.selenium.remote.CapabilityType; | ||
import org.openqa.selenium.remote.Command; | ||
import org.openqa.selenium.remote.CommandExecutor; | ||
import org.openqa.selenium.remote.DriverCommand; | ||
import org.openqa.selenium.remote.RemoteWebDriver; | ||
import org.openqa.selenium.remote.RemoteWebDriverBuilder; | ||
import org.openqa.selenium.remote.SessionId; | ||
import org.openqa.selenium.remote.UnreachableBrowserException; | ||
import org.openqa.selenium.support.ui.ExpectedCondition; | ||
|
@@ -51,6 +52,9 @@ | |
import java.io.File; | ||
import java.io.IOException; | ||
import java.lang.reflect.Field; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.nio.file.Path; | ||
import java.time.Duration; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
@@ -521,20 +525,42 @@ public void testFirefoxCanNativelyClickOverlappingElements() { | |
} | ||
|
||
@Test | ||
public void shouldAllowRemoteWebDriversToBeAugmentedWithHasExtensions() { | ||
public void shouldAddExtensions() { | ||
Path extension = InProject.locate("third_party/firebug/favourite_colour-1.1-an+fx.xpi"); | ||
|
||
((FirefoxDriver) driver).installExtension(extension); | ||
((FirefoxDriver) driver).uninstallExtension("[email protected]"); | ||
} | ||
|
||
@Test | ||
public void shouldAllowRemoteWebDriverBuilderToUseHasExtensions() { | ||
WebDriver driver = RemoteWebDriver.builder() | ||
.oneOf(new FirefoxOptions()) | ||
.address("http://localhost:4444/") | ||
.build(); | ||
|
||
try { | ||
assertThat(driver).isInstanceOf(HasExtensions.class); | ||
fail(driver.getClass().getName()); | ||
Path extension = InProject.locate("third_party/firebug/favourite_colour-1.1-an+fx.xpi"); | ||
((HasExtensions) driver).installExtension(extension); | ||
((HasExtensions) driver).uninstallExtension("[email protected]"); | ||
} finally { | ||
driver.quit(); | ||
} | ||
} | ||
|
||
@Test | ||
public void shouldAllowDriverToBeAugmentedWithHasExtensions() throws MalformedURLException { | ||
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/"), new FirefoxOptions()); | ||
WebDriver augmentedDriver = new Augmenter().augment(driver); | ||
|
||
try { | ||
Path extension = InProject.locate("third_party/firebug/favourite_colour-1.1-an+fx.xpi"); | ||
((HasExtensions) augmentedDriver).installExtension(extension); | ||
((HasExtensions) augmentedDriver).uninstallExtension("[email protected]"); | ||
} finally { | ||
driver.quit(); | ||
} | ||
} | ||
|
||
private static class CustomFirefoxProfile extends FirefoxProfile {} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters