Example usage for org.openqa.selenium.io FileHandler copy

List of usage examples for org.openqa.selenium.io FileHandler copy

Introduction

In this page you can find the example usage for org.openqa.selenium.io FileHandler copy.

Prototype

public static void copy(File from, File to) throws IOException 

Source Link

Usage

From source file:crazy.seleiumTools.ProfilesIni.java

License:Apache License

public FirefoxProfile getDefaultProfile() {
    String profileName = this.nameOfpro;
    File profileDir = profiles.get(profileName);
    if (profileDir == null)
        return null;

    // Make a copy of the profile to use
    File tempDir = TemporaryFilesystem.getDefaultTmpFS().createTempDir("userprofile", "copy");
    try {/*from   www  .  j av  a 2 s.  c om*/
        FileHandler.copy(profileDir, tempDir);

        // Delete the old compreg.dat file so that our new extension is registered
        File compreg = new File(tempDir, "compreg.dat");
        if (compreg.exists()) {
            if (!compreg.delete()) {
                throw new WebDriverException("Cannot delete file from copy of profile " + profileName);
            }
        }
    } catch (IOException e) {
        throw new WebDriverException(e);
    }

    return new FirefoxProfile(tempDir);
}

From source file:crazy.seleiumTools.ProfilesIni.java

License:Apache License

public FirefoxProfile getProfile(String profileName) {
    File profileDir = profiles.get(profileName);
    if (profileDir == null)
        return null;

    // Make a copy of the profile to use
    File tempDir = TemporaryFilesystem.getDefaultTmpFS().createTempDir("userprofile", "copy");
    try {/*from w w w.  j  a va  2 s.  c om*/
        FileHandler.copy(profileDir, tempDir);

        // Delete the old compreg.dat file so that our new extension is registered
        File compreg = new File(tempDir, "compreg.dat");
        if (compreg.exists()) {
            if (!compreg.delete()) {
                throw new WebDriverException("Cannot delete file from copy of profile " + profileName);
            }
        }
    } catch (IOException e) {
        throw new WebDriverException(e);
    }

    return new FirefoxProfile(tempDir);
}