Skip to content

Commit

Permalink
[java] Adding a test for extension installation and deinstallation in…
Browse files Browse the repository at this point in the history
… Firefox
  • Loading branch information
barancev committed Sep 25, 2018
1 parent 5593155 commit 10869bb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Expand Up @@ -219,7 +219,8 @@ private static boolean isLegacy(Capabilities desiredCapabilities) {
@Override
public String installExtension(Path path) {
return (String) execute(ExtraCommands.INSTALL_EXTENSION,
singletonMap("path", path.toAbsolutePath().toString())).getValue();
ImmutableMap.of("path", path.toAbsolutePath().toString(),
"temporary", false)).getValue();
}

@Override
Expand Down
Expand Up @@ -20,6 +20,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeNotNull;
import static org.junit.Assume.assumeTrue;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -53,6 +54,7 @@
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.testing.Ignore;
import org.openqa.selenium.testing.InProject;
import org.openqa.selenium.testing.JUnit4TestBase;
import org.openqa.selenium.testing.NeedsFreshDriver;
import org.openqa.selenium.testing.NeedsLocalEnvironment;
Expand All @@ -64,13 +66,16 @@
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

@NeedsLocalEnvironment(reason = "Requires local browser launching environment")
public class FirefoxDriverTest extends JUnit4TestBase {

private static final String MOOLTIPASS_PATH = "third_party/firebug/mooltipass-1.1.87.xpi";

private FirefoxDriver localDriver;

@After
Expand Down Expand Up @@ -518,6 +523,15 @@ public void testFirefoxCanNativelyClickOverlappingElements() {
+ "click in over (handled by body)");
}

@Test
public void canInstallAndUninstallExtensionsOnTheFly() {
assumeTrue(driver instanceof FirefoxDriver);
FirefoxDriver localDriver = (FirefoxDriver) driver;
Path extension = InProject.locate(MOOLTIPASS_PATH);
String extId = localDriver.installExtension(extension);
localDriver.uninstallExtension(extId);
}

private static class CustomFirefoxProfile extends FirefoxProfile {}

}

0 comments on commit 10869bb

Please sign in to comment.