Ejemplo n.º 1
0
  public FirefoxProfile createCopy(int port) {
    File tmpDir = new File(System.getProperty("java.io.tmpdir"));
    File to = new File(tmpDir, "webdriver-" + System.currentTimeMillis());
    to.mkdirs();

    FileHandler.copyDir(profileDir, to);
    FirefoxProfile profile = new FirefoxProfile(to);
    profile.addAdditionalPreferences(additionalPrefs);
    profile.setPort(port);
    profile.updateUserPrefs();

    return profile;
  }
Ejemplo n.º 2
0
  /**
   * Attempt to add an extension to install into this instance.
   *
   * @param extensionToInstall
   * @throws IOException
   */
  public void addExtension(File extensionToInstall) throws IOException {
    if (!extensionToInstall.isDirectory()
        && !FileHandler.isZipped(extensionToInstall.getAbsolutePath())) {
      throw new IOException("Can only install from a zip file, an XPI or a directory");
    }

    File root = obtainRootDirectory(extensionToInstall);

    String id = readIdFromInstallRdf(root);

    File extensionDirectory = new File(extensionsDir, id);

    if (extensionDirectory.exists() && !FileHandler.delete(extensionDirectory)) {
      throw new IOException("Unable to delete existing extension directory: " + extensionDirectory);
    }

    FileHandler.createDir(extensionDirectory);
    FileHandler.makeWritable(extensionDirectory);
    FileHandler.copyDir(root, extensionDirectory);
  }