Esempio n. 1
1
  public void addExtension(Class<?> loadResourcesUsing, String loadFrom) throws IOException {
    // Is loadFrom a file?
    File file = new File(loadFrom);
    if (file.exists()) {
      addExtension(file);
      return;
    }

    // Try and load it from the classpath
    InputStream resource = loadResourcesUsing.getResourceAsStream(loadFrom);
    if (resource == null && !loadFrom.startsWith("/")) {
      resource = loadResourcesUsing.getResourceAsStream("/" + loadFrom);
    }
    if (resource == null) {
      resource = FirefoxProfile.class.getResourceAsStream(loadFrom);
    }
    if (resource == null && !loadFrom.startsWith("/")) {
      resource = FirefoxProfile.class.getResourceAsStream("/" + loadFrom);
    }
    if (resource == null) {
      throw new FileNotFoundException("Cannot locate resource with name: " + loadFrom);
    }

    File root;
    if (FileHandler.isZipped(loadFrom)) {
      root = FileHandler.unzip(resource);
    } else {
      throw new RuntimeException("Will only install zipped extensions for now");
    }

    addExtension(root);
  }
Esempio n. 2
0
  public void addExtension(Class<?> loadResourcesUsing, String loadFrom) {
    // Is loadFrom a file?
    File file = new File(loadFrom);
    if (file.exists()) {
      addExtension(file);
      return;
    }

    addExtension(loadFrom, new ClasspathExtension(loadResourcesUsing, loadFrom));
  }
 @Test
 public void shouldInstallExtensionFromZip() throws IOException {
   FirefoxProfile profile = new FirefoxProfile();
   profile.addExtension(InProject.locate(FIREBUG_PATH));
   File profileDir = profile.layoutOnDisk();
   File extensionDir = new File(profileDir, "extensions/[email protected]");
   assertTrue(extensionDir.exists());
 }
 @Test
 public void shouldInstallExtensionUsingClasspath() throws IOException {
   FirefoxProfile profile = new FirefoxProfile();
   profile.addExtension(
       FirefoxProfileTest.class, "/org/openqa/selenium/testing/drivers/firebug-1.5.0-fx.xpi");
   File profileDir = profile.layoutOnDisk();
   File extensionDir = new File(profileDir, "extensions/[email protected]");
   assertTrue(extensionDir.exists());
 }
 @Test
 public void shouldInstallExtensionFromDirectory() throws IOException {
   FirefoxProfile profile = new FirefoxProfile();
   File extension = InProject.locate(FIREBUG_PATH);
   File unzippedExtension = FileHandler.unzip(new FileInputStream(extension));
   profile.addExtension(unzippedExtension);
   File profileDir = profile.layoutOnDisk();
   File extensionDir = new File(profileDir, "extensions/[email protected]");
   assertTrue(extensionDir.exists());
 }
Esempio n. 6
0
  protected void addWebDriverExtensionIfNeeded(boolean forceCreation) throws IOException {
    File extensionLocation = new File(extensionsDir, EXTENSION_NAME);
    if (!forceCreation && extensionLocation.exists()) return;

    boolean isDev = Boolean.getBoolean("webdriver.firefox.development");
    if (isDev) {
      installDevelopmentExtension();
    } else {
      addExtension(FirefoxProfile.class, "webdriver-extension.zip");
    }

    deleteExtensionsCacheIfItExists();
  }
Esempio n. 7
0
  protected void addWebDriverExtensionIfNeeded(boolean forceCreation) throws IOException {
    File extensionLocation = new File(extensionsDir, EXTENSION_NAME);
    if (!forceCreation && extensionLocation.exists()) return;

    String home = System.getProperty("webdriver.firefox.development");
    if (home != null) {
      System.out.println("Installing developer version");
      installDevelopmentExtension(home);
    } else {
      addExtension(FirefoxProfile.class, "webdriver-extension.zip");
    }

    deleteExtensionsCacheIfItExists();
  }
  public DesiredCapabilities getFirefoxCapabilities() throws IOException {

    TryFunction<String, String> path =
        location -> Paths.get(ClassLoader.getSystemResource(location).toURI()).toString();

    String firebugPath = path.apply("firebug_plugin/firebug-2.0.11-fx.xpi");
    String firePathPath = path.apply("firebug_plugin/firepath-0.9.7.1-fx.xpi");
    String netExportPath = path.apply("firebug_plugin/netExport-0.9b6.xpi");

    FirefoxProfile firefoxProfile = new FirefoxProfile();
    firefoxProfile.addExtension(new File(firebugPath));
    firefoxProfile.addExtension(new File(firePathPath));
    firefoxProfile.addExtension(new File(netExportPath));
    firefoxProfile.setPreference("browser.download.folderList", 2);
    firefoxProfile.setPreference("extensions.firebug.currentVersion", "2.0.11");
    firefoxProfile.setPreference("extensions.firebug.onByDefault", true);
    firefoxProfile.setPreference("extensions.firebug.previousPlacement", 2);
    firefoxProfile.setPreference("extensions.firebug.netFilterCategories", "xhr");
    firefoxProfile.setPreference("extensions.firebug.defaultPanelName", "net");
    firefoxProfile.setPreference("extensions.firebug.net.enableSites", true);
    firefoxProfile.setPreference("extensions.firebug.net.persistent", true);
    firefoxProfile.setPreference("extensions.firebug.netexport.autoExportToServer", false);
    firefoxProfile.setPreference(
        "extensions.firebug.netexport.defaultLogDir", System.getProperty("user.dir"));
    firefoxProfile.setPreference("extensions.firebug.netexport.showPreview", false);
    firefoxProfile.setPreference("extensions.firebug.netexport.sendToConfirmation", false);
    firefoxProfile.setPreference("extensions.firebug.netexport.pageLoadedTimeout", 360000);
    firefoxProfile.setPreference("extensions.firebug.netexport.timeout", 360000);
    firefoxProfile.setPreference("extensions.firebug.netexport.Automation", true);
    firefoxProfile.setPreference("extensions.firebug.netexport.compress", false);
    firefoxProfile.setPreference("extensions.firebug.netexport.includeResponseBodies", true);
    DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    capabilities.setCapability("marionette", true);
    capabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
    return addProxySettings(capabilities, proxy());
  }
Esempio n. 9
0
  protected void addWebDriverExtensionIfNeeded(boolean forceCreation) {
    File extensionLocation = new File(extensionsDir, EXTENSION_NAME);
    if (!forceCreation && extensionLocation.exists()) {
      return;
    }

    try {
      addExtension(FirefoxProfile.class, "webdriver-extension.zip");
    } catch (IOException e) {
      if (!Boolean.getBoolean("webdriver.development")) {
        throw new WebDriverException("Failed to install webdriver extension", e);
      }
    }

    deleteExtensionsCacheIfItExists();
  }
Esempio n. 10
0
 /**
  * Attempt to add an extension to install into this instance.
  *
  * @param extensionToInstall File pointing to the extension
  */
 public void addExtension(File extensionToInstall) {
   addExtension(extensionToInstall.getName(), new FileExtension(extensionToInstall));
 }