Package org.openqa.selenium.firefox
Class FirefoxProfile
- java.lang.Object
-
- org.openqa.selenium.firefox.FirefoxProfile
-
public class FirefoxProfile extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ALLOWED_HOSTS_PREFERENCE
static java.lang.String
PORT_PREFERENCE
-
Constructor Summary
Constructors Modifier Constructor Description FirefoxProfile()
FirefoxProfile(java.io.File profileDir)
Constructs a firefox profile from an existing profile directory.protected
FirefoxProfile(java.io.Reader defaultsReader, java.io.File profileDir)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addExtension(java.io.File extensionToInstall)
Attempt to add an extension to install into this instance.void
addExtension(java.lang.Class<?> loadResourcesUsing, java.lang.String loadFrom)
void
addExtension(java.lang.String key, Extension extension)
void
checkForChangesInFrozenPreferences()
void
clean(java.io.File profileDir)
void
cleanTemporaryModel()
boolean
containsWebDriverExtension()
protected void
copyModel(java.io.File sourceDir, java.io.File profileDir)
void
deleteExtensionsCacheIfItExists(java.io.File profileDir)
protected void
deleteLockFiles(java.io.File profileDir)
static FirefoxProfile
fromJson(java.lang.String json)
protected org.openqa.selenium.firefox.Preferences
getAdditionalPreferences()
boolean
getBooleanPreference(java.lang.String key, boolean defaultValue)
int
getIntegerPreference(java.lang.String key, int defaultValue)
java.lang.String
getStringPreference(java.lang.String key, java.lang.String defaultValue)
protected void
installExtensions(java.io.File parentDir)
java.io.File
layoutOnDisk()
Call this to cause the current profile to be written to disk.protected java.io.Reader
onlyOverrideThisIfYouKnowWhatYouAreDoing()
Internal method.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
setPreference(java.lang.String key, java.lang.Object value)
boolean
shouldLoadNoFocusLib()
Returns whether the no focus library should be loaded for Firefox profiles launched on Linux, even if native events are disabled.void
updateUserPrefs(java.io.File userPrefs)
-
-
-
Field Detail
-
PORT_PREFERENCE
public static final java.lang.String PORT_PREFERENCE
- See Also:
- Constant Field Values
-
ALLOWED_HOSTS_PREFERENCE
public static final java.lang.String ALLOWED_HOSTS_PREFERENCE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FirefoxProfile
public FirefoxProfile()
-
FirefoxProfile
public FirefoxProfile(java.io.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.
-
FirefoxProfile
@Beta protected FirefoxProfile(java.io.Reader defaultsReader, java.io.File profileDir)
-
-
Method Detail
-
onlyOverrideThisIfYouKnowWhatYouAreDoing
@Beta protected java.io.Reader onlyOverrideThisIfYouKnowWhatYouAreDoing()
Internal method. This is liable to change at a moment's notice.- Returns:
- InputStreamReader of the default firefox profile preferences
-
getStringPreference
public java.lang.String getStringPreference(java.lang.String key, java.lang.String defaultValue)
-
getIntegerPreference
public int getIntegerPreference(java.lang.String key, int defaultValue)
-
getBooleanPreference
public boolean getBooleanPreference(java.lang.String key, boolean defaultValue)
-
containsWebDriverExtension
public boolean containsWebDriverExtension()
-
addExtension
public void addExtension(java.lang.Class<?> loadResourcesUsing, java.lang.String loadFrom)
-
addExtension
public void addExtension(java.io.File extensionToInstall)
Attempt to add an extension to install into this instance.- Parameters:
extensionToInstall
- File pointing to the extension
-
addExtension
public void addExtension(java.lang.String key, Extension extension)
-
setPreference
public void setPreference(java.lang.String key, java.lang.Object value)
-
getAdditionalPreferences
protected org.openqa.selenium.firefox.Preferences getAdditionalPreferences()
-
updateUserPrefs
public void updateUserPrefs(java.io.File userPrefs)
-
deleteLockFiles
protected void deleteLockFiles(java.io.File profileDir)
-
deleteExtensionsCacheIfItExists
public void deleteExtensionsCacheIfItExists(java.io.File profileDir)
-
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.
-
clean
public void clean(java.io.File profileDir)
-
fromJson
public static FirefoxProfile fromJson(java.lang.String json) throws java.io.IOException
- Throws:
java.io.IOException
-
cleanTemporaryModel
public void cleanTemporaryModel()
-
checkForChangesInFrozenPreferences
public void checkForChangesInFrozenPreferences()
-
layoutOnDisk
public java.io.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 theFirefoxDriver
.- Returns:
- The directory containing the profile.
-
copyModel
protected void copyModel(java.io.File sourceDir, java.io.File profileDir) throws java.io.IOException
- Throws:
java.io.IOException
-
installExtensions
protected void installExtensions(java.io.File parentDir) throws java.io.IOException
- Throws:
java.io.IOException
-
-