org.openqa.selenium.firefox
Class FirefoxProfile

java.lang.Object
  extended by org.openqa.selenium.firefox.FirefoxProfile

public class FirefoxProfile
extends Object


Field Summary
static String PORT_PREFERENCE
           
 
Constructor Summary
FirefoxProfile()
           
FirefoxProfile(File profileDir)
          Constructs a firefox profile from an existing profile directory.
 
Method Summary
 void addExtension(Class<?> loadResourcesUsing, String loadFrom)
           
 void addExtension(File extensionToInstall)
          Attempt to add an extension to install into this instance.
protected  void addExtension(String key, Extension extension)
           
protected  void addWebDriverExtensionIfNeeded()
           
 boolean areNativeEventsEnabled()
           
 void clean(File profileDir)
           
protected  void copyModel(File sourceDir, File profileDir)
           
 void deleteExtensionsCacheIfItExists(File profileDir)
           
protected  void deleteLockFiles(File profileDir)
           
static FirefoxProfile fromJson(String json)
           
protected  org.openqa.selenium.firefox.Preferences getAdditionalPreferences()
           
protected  void installExtensions(File parentDir)
           
 boolean isRunning(File profileDir)
           
 File layoutOnDisk()
          Call this to cause the current profile to be written to disk.
 void setAcceptUntrustedCertificates(boolean acceptUntrustedSsl)
          Sets whether Firefox should accept SSL certificates which have expired, signed by an unknown authority or are generally untrusted.
 void setAlwaysLoadNoFocusLib(boolean loadNoFocusLib)
          Sets whether the no focus library should always be loaded on Linux.
 void setAssumeUntrustedCertificateIssuer(boolean untrustedIssuer)
          By default, when accepting untrusted SSL certificates, assume that these certificates will come from an untrusted issuer or will be self signed.
 void setEnableNativeEvents(boolean enableNativeEvents)
           
 void setPreference(String key, boolean value)
          Set a preference for this particular profile.
 void setPreference(String key, int value)
          Set a preference for this particular profile.
 void setPreference(String key, String value)
          Set a preference for this particular profile.
 FirefoxProfile setProxyPreferences(org.openqa.selenium.Proxy proxy)
          Set proxy preferences for this profile.
 boolean shouldLoadNoFocusLib()
          Returns whether the no focus library should be loaded for Firefox profiles launched on Linux, even if native events are disabled.
 String toJson()
           
 void updateUserPrefs(File userPrefs)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PORT_PREFERENCE

public static final String PORT_PREFERENCE
See Also:
Constant Field Values
Constructor Detail

FirefoxProfile

public FirefoxProfile()

FirefoxProfile

public FirefoxProfile(File profileDir)
Constructs a firefox profile from an existing profile directory.

Users who need this functionality should consider using a named profile.

Parameters:
profileDir - The profile directory to use as a model.
Method Detail

addWebDriverExtensionIfNeeded

protected void addWebDriverExtensionIfNeeded()

addExtension

public void addExtension(Class<?> loadResourcesUsing,
                         String loadFrom)
                  throws IOException
Throws:
IOException

addExtension

public void addExtension(File extensionToInstall)
                  throws IOException
Attempt to add an extension to install into this instance.

Parameters:
extensionToInstall -
Throws:
IOException

addExtension

protected void addExtension(String key,
                            Extension extension)

setPreference

public void setPreference(String key,
                          String value)
Set a preference for this particular profile. The value will be properly quoted before use. Note that if a value looks as if it is a quoted string (that is, starts with a quote character and ends with one too) an IllegalArgumentException is thrown: Firefox fails to start properly when some values are set to this.

Parameters:
key - The key
value - The new value.

setPreference

public void setPreference(String key,
                          boolean value)
Set a preference for this particular profile.

Parameters:
key - The key
value - The new value.

setPreference

public void setPreference(String key,
                          int value)
Set a preference for this particular profile.

Parameters:
key - The key
value - The new value.

setProxyPreferences

public FirefoxProfile setProxyPreferences(org.openqa.selenium.Proxy proxy)
Set proxy preferences for this profile.

Parameters:
proxy - The proxy preferences.
Returns:
The profile, for further settings.

getAdditionalPreferences

protected org.openqa.selenium.firefox.Preferences getAdditionalPreferences()

updateUserPrefs

public void updateUserPrefs(File userPrefs)

deleteLockFiles

protected void deleteLockFiles(File profileDir)

deleteExtensionsCacheIfItExists

public void deleteExtensionsCacheIfItExists(File profileDir)

areNativeEventsEnabled

public boolean areNativeEventsEnabled()

setEnableNativeEvents

public void setEnableNativeEvents(boolean enableNativeEvents)

shouldLoadNoFocusLib

public boolean shouldLoadNoFocusLib()
Returns whether the no focus library should be loaded for Firefox profiles launched on Linux, even if native events are disabled.

Returns:
Whether the no focus library should always be loaded for Firefox on Linux.

setAlwaysLoadNoFocusLib

public void setAlwaysLoadNoFocusLib(boolean loadNoFocusLib)
Sets whether the no focus library should always be loaded on Linux.

Parameters:
loadNoFocusLib - Whether to always load the no focus library.

setAcceptUntrustedCertificates

public void setAcceptUntrustedCertificates(boolean acceptUntrustedSsl)
Sets whether Firefox should accept SSL certificates which have expired, signed by an unknown authority or are generally untrusted. This is set to true by default.

Parameters:
acceptUntrustedSsl - Whether untrusted SSL certificates should be accepted.

setAssumeUntrustedCertificateIssuer

public void setAssumeUntrustedCertificateIssuer(boolean untrustedIssuer)
By default, when accepting untrusted SSL certificates, assume that these certificates will come from an untrusted issuer or will be self signed. Due to limitation within Firefox, it is easy to find out if the certificate has expired or does not match the host it was served for, but hard to find out if the issuer of the certificate is untrusted.

By default, it is assumed that the certificates were not be issued from a trusted CA.

If you are receive an "untrusted site" prompt on Firefox when using a certificate that was issued by valid issuer, but has expired or is being served served for a different host (e.g. production certificate served in a testing environment) set this to false.

Parameters:
untrustedIssuer - whether to assume untrusted issuer or not.

isRunning

public boolean isRunning(File profileDir)

clean

public void clean(File profileDir)

toJson

public String toJson()
              throws IOException
Throws:
IOException

fromJson

public static FirefoxProfile fromJson(String json)
                               throws IOException
Throws:
IOException

layoutOnDisk

public File layoutOnDisk()
Call this to cause the current profile to be written to disk. The profile directory is returned. Note that this profile directory is a temporary one and will be deleted when the JVM exists (at the latest) This method should be called immediately before starting to use the profile and should only be called once per instance of the FirefoxDriver.

Returns:
The directory containing the profile.

copyModel

protected void copyModel(File sourceDir,
                         File profileDir)
                  throws IOException
Throws:
IOException

installExtensions

protected void installExtensions(File parentDir)
                          throws IOException
Throws:
IOException


Copyright © 2012. All Rights Reserved.