public class SafariOptions extends Object
SafariDriver.
Example usage:
SafariOptions options = new SafariOptions()
// Add an extra extension
options.addExtensions(new File("/path/to/extension.safariextz"));
// For use with SafariDriver:
SafariDriver driver = new SafariDriver(options);
// For use with RemoteWebDriver:
DesiredCapabilities capabilities = DesiredCapabilities.safari();
capabilities.setCapability(SafariOptions.CAPABILITY, options);
RemoteWebDriver driver = new RemoteWebDriver(
new URL("http://localhost:4444/wd/hub"), capabilities);
| Modifier and Type | Field and Description |
|---|---|
static String |
CAPABILITY
Key used to store SafariOptions in a
DesiredCapabilities object. |
| Constructor and Description |
|---|
SafariOptions() |
| Modifier and Type | Method and Description |
|---|---|
void |
addExtensions(File... paths) |
void |
addExtensions(List<File> paths)
Adds a new Safari extension to install on browser startup.
|
boolean |
equals(Object other) |
static SafariOptions |
fromCapabilities(org.openqa.selenium.Capabilities capabilities)
Construct a
SafariOptions instance from given capabilites. |
com.google.common.base.Optional<File> |
getDataDir() |
List<File> |
getExtensions() |
int |
getPort() |
boolean |
getSkipExtensionInstallation() |
boolean |
getUseCleanSession() |
boolean |
getUseCustomDriverExtension() |
int |
hashCode() |
void |
setDataDir(File dataDir)
Specifies the location of Safari installation's data directory.
|
void |
setDriverExtension(File driverExtension)
Override the SafariDriver Safari extension.
|
void |
setPort(int port)
Set the port the
SafariDriverServer should be started on. |
void |
setSkipExtensionInstallation(boolean skipExtensionInstallation)
Whether to skip extension installation.
|
void |
setUseCleanSession(boolean useCleanSession)
Instruct the SafariDriver to delete all existing session data when starting a new session.
|
org.json.JSONObject |
toJson()
Converts this instance to its JSON representation.
|
public static final String CAPABILITY
DesiredCapabilities object.public static SafariOptions fromCapabilities(org.openqa.selenium.Capabilities capabilities) throws org.openqa.selenium.WebDriverException
SafariOptions instance from given capabilites.
When the CAPABILITY capability is set, all other capabilities will be ignored!capabilities - Desired capabilities from which the options are derived.org.openqa.selenium.WebDriverException - If an error occurred during the reconstruction of the optionspublic void addExtensions(File... paths)
paths - Paths to the extensions to install.addExtensions(java.util.List)public void addExtensions(List<File> paths)
Use setDriverExtension(File) if you want to install a custom Safari Driver
extension.
paths - Paths to the extensions to install.public void setDataDir(File dataDir)
dataDir - A File object pointing to the Safari installation's data directory.
If null, the default installation location for the current platform will be used.public void setDriverExtension(File driverExtension)
driverExtension - A .safariextz file which is compatible with the SafariDriver.
If null, the default driver extension is used.public void setPort(int port)
SafariDriverServer should be started on. Defaults to 0, in which case
the server selects a free port.port - The port the SafariDriverServer should be started on,
or 0 if the server should select a free port.public void setSkipExtensionInstallation(boolean skipExtensionInstallation)
addExtensions(java.util.List) and
setDriverExtension(File).skipExtensionInstallation - If true, the installation of extensions is skipped.public void setUseCleanSession(boolean useCleanSession)
Warning: Since Safari uses a single profile for the current user, enabling this capability will permanently erase any existing session data.
useCleanSession - If true, the SafariDriver will erase all existing session data.public com.google.common.base.Optional<File> getDataDir()
setDataDir(File)public List<File> getExtensions()
setDriverExtension(File)), then it will be the first element of this list.addExtensions(java.util.List)public int getPort()
SafariDriverServer should be started on.
If 0, the server should select a free port.setPort(int)public boolean getSkipExtensionInstallation()
setSkipExtensionInstallation(boolean)public boolean getUseCustomDriverExtension()
setDriverExtension(File),
setSkipExtensionInstallation(boolean)public boolean getUseCleanSession()
setUseCleanSession(boolean)public org.json.JSONObject toJson()
throws IOException,
org.json.JSONException
IOException - If an error occurred while reading the Safari extension files.org.json.JSONExceptionCopyright © 2013. All rights reserved.