com.opera.core.systems
Class OperaProfile

java.lang.Object
  extended by com.opera.core.systems.OperaProfile

public class OperaProfile
extends Object

OperaProfile is an interface representing a profile (commonly a profile directory) for the Opera web browser. It's typically used by passing in an instance object of this class to the "opera.profile" capability at construction of OperaDriver, like this:

 DesiredCapabilities capabilities = DesiredCapabilities.opera();
   OperaProfile profile = new OperaProfile();

   profile.preferences().set("foo", "bar", "baz");
   capabilities.setCapability("opera.profile", profile);

   WebDriver driver = new OperaDriver(capabilities);
 
 
Or by passing it in as an object directly to OperaDriver's constructor:
 OperaProfile profile = new OperaProfile();
   profile.preferences().set("foo", "bar", "baz");

   WebDriver driver = new OperaDriver(profile);
 
 
Among Opera's command-line arguments the profile may be referred to as "pd", short for "personal directory".

See Also:
OperaPreferences

Constructor Summary
OperaProfile()
          Creates a new, fresh random profile for Opera to use.
OperaProfile(File profileDirectory)
          Creates a representation of the profile in the given directory.
OperaProfile(String profileDirectoryPath)
          Creates a representation of the profile in the given directory path.
 
Method Summary
 void cleanUp()
          Cleans up the profile.
static OperaProfile fromJson(String json)
          Converts a JSON string object to a profile representation, returning a new instance of OperaProfile.
 File getDirectory()
          Gets the current profile directory.
 OperaPreferences preferences()
          Allows access to the preferences in the current profile.
 void setPreferences(OperaPreferences newPreferences)
          Replaces the preferences in the profile with the given preferences.
 String toJson()
          Converts this instance to its JSON representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OperaProfile

public OperaProfile()
Creates a new, fresh random profile for Opera to use. The actual profile directory will not be generated until Opera is started. This is supported on all products that have the -pd command-line argument, such as Opera Desktop. core-gogi and Opera Mobile is not supported.


OperaProfile

public OperaProfile(String profileDirectoryPath)
Creates a representation of the profile in the given directory path. If you specify a profile directory that does not exist Opera will generate a new, fresh profile in the same location when it is started.

Parameters:
profileDirectoryPath - the path to the profile directory to use

OperaProfile

public OperaProfile(File profileDirectory)
Creates a representation of the profile in the given directory. If you specify a profile directory that does not exist Opera will generate a new, fresh profile in the same location when it is started.

Parameters:
profileDirectory - the profile to use
Throws:
IllegalArgumentException - if profileDirectory is not set
Method Detail

preferences

public OperaPreferences preferences()
Allows access to the preferences in the current profile.

Returns:
an OperaPreferences object representing preferences in the current profile

setPreferences

public void setPreferences(OperaPreferences newPreferences)
Replaces the preferences in the profile with the given preferences.

Parameters:
newPreferences - the new preferences to populate the profile with

getDirectory

public File getDirectory()
Gets the current profile directory.

Returns:
the directory where this profile is stored

cleanUp

public void cleanUp()
Cleans up the profile. If the profile was random, it will be deleted. This method should typically be called when Opera is shut down.


toJson

public String toJson()
              throws IOException
Converts this instance to its JSON representation.

Returns:
the JSON representation of this profile
Throws:
IOException - if an I/O error occurs

fromJson

public static OperaProfile fromJson(String json)
                             throws IOException
Converts a JSON string object to a profile representation, returning a new instance of OperaProfile. This is used by the JsonWireProtocol to transfer a profile.

Parameters:
json - a base64-encoded JSON string (archive) representing a profile
Returns:
a new profile representation
Throws:
IOException - if an I/O error occurs


Copyright © 2012. All Rights Reserved.