Package com.thoughtworks.selenium
Class BrowserConfigurationOptions
- java.lang.Object
-
- com.thoughtworks.selenium.BrowserConfigurationOptions
-
public class BrowserConfigurationOptions extends java.lang.Object
Contains parameters for a single Selenium browser session. BrowserConfigurationOptions is used as an argument toSelenium.start()
. The parameters set within will override any command-line parameters set for the same option.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
BROWSER_EXECUTABLE_PATH
static java.lang.String
BROWSER_MODE
static java.lang.String
COMMAND_LINE_FLAGS
static int
DEFAULT_TIMEOUT_IN_SECONDS
static java.lang.String
MULTI_WINDOW
static java.lang.String
PROFILE_NAME
static java.lang.String
PROXY_CONFIG
static java.lang.String
SINGLE_WINDOW
static java.lang.String
TIMEOUT_IN_SECONDS
-
Constructor Summary
Constructors Constructor Description BrowserConfigurationOptions()
Instantiate a blank BrowserConfigurationOptions instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
canUse(java.lang.String value)
java.lang.String
get(java.lang.String key)
protected java.lang.String
getBrowserExecutablePath()
protected java.lang.String
getBrowserMode()
java.lang.String
getCommandLineFlags()
protected java.lang.String
getProfile()
protected int
getTimeoutInSeconds()
boolean
hasOptions()
Returns true if any options are set in this instance.protected boolean
isMultiWindow()
Returns true if theMULTI_WINDOW
field is set.boolean
isSet(java.lang.String key)
protected boolean
isSingleWindow()
Returns true if theSINGLE_WINDOW
field is set.java.lang.String
serialize()
Serializes to the format "name=value;name=value".BrowserConfigurationOptions
set(java.lang.String key, java.lang.String value)
Sets the given key to the given value unless the value is null.BrowserConfigurationOptions
setBrowserExecutablePath(java.lang.String executablePath)
Sets the full path for the browser executable.BrowserConfigurationOptions
setBrowserMode(java.lang.String mode)
Sets the "mode" for the browser.BrowserConfigurationOptions
setCommandLineFlags(java.lang.String cmdLineFlags)
BrowserConfigurationOptions
setMultiWindow()
SetsMULTI_WINDOW
and unsetsSINGLE_WINDOW
BrowserConfigurationOptions
setProfile(java.lang.String profile)
Sets the name of the profile, which must exist in the -profilesLocation directory, to use for this browser session.BrowserConfigurationOptions
setSingleWindow()
SetsSINGLE_WINDOW
and unsetsMULTI_WINDOW
.BrowserConfigurationOptions
setTimeoutInSeconds(int timeout)
Sets the timeout, in seconds, for all commands.java.lang.String
toString()
-
-
-
Field Detail
-
PROXY_CONFIG
public static final java.lang.String PROXY_CONFIG
- See Also:
- Constant Field Values
-
PROFILE_NAME
public static final java.lang.String PROFILE_NAME
- See Also:
- Constant Field Values
-
SINGLE_WINDOW
public static final java.lang.String SINGLE_WINDOW
- See Also:
- Constant Field Values
-
MULTI_WINDOW
public static final java.lang.String MULTI_WINDOW
- See Also:
- Constant Field Values
-
BROWSER_EXECUTABLE_PATH
public static final java.lang.String BROWSER_EXECUTABLE_PATH
- See Also:
- Constant Field Values
-
TIMEOUT_IN_SECONDS
public static final java.lang.String TIMEOUT_IN_SECONDS
- See Also:
- Constant Field Values
-
BROWSER_MODE
public static final java.lang.String BROWSER_MODE
- See Also:
- Constant Field Values
-
COMMAND_LINE_FLAGS
public static final java.lang.String COMMAND_LINE_FLAGS
- See Also:
- Constant Field Values
-
DEFAULT_TIMEOUT_IN_SECONDS
public static final int DEFAULT_TIMEOUT_IN_SECONDS
- See Also:
- Constant Field Values
-
-
Method Detail
-
hasOptions
public boolean hasOptions()
Returns true if any options are set in this instance.- Returns:
- true if any options are set in this instance.
-
serialize
public java.lang.String serialize()
Serializes to the format "name=value;name=value".- Returns:
- String with the above format.
-
setProfile
public BrowserConfigurationOptions setProfile(java.lang.String profile)
Sets the name of the profile, which must exist in the -profilesLocation directory, to use for this browser session.- Parameters:
profile
- the name of the profile.- Returns:
- this BrowserConfigurationOptions object.
-
getProfile
protected java.lang.String getProfile()
-
isSingleWindow
protected boolean isSingleWindow()
Returns true if theSINGLE_WINDOW
field is set.- Returns:
- true if
SINGLE_WINDOW
is set.
-
isMultiWindow
protected boolean isMultiWindow()
Returns true if theMULTI_WINDOW
field is set.- Returns:
- true if
MULTI_WINDOW
is set.
-
setSingleWindow
public BrowserConfigurationOptions setSingleWindow()
SetsSINGLE_WINDOW
and unsetsMULTI_WINDOW
.- Returns:
- this / self
-
setMultiWindow
public BrowserConfigurationOptions setMultiWindow()
SetsMULTI_WINDOW
and unsetsSINGLE_WINDOW
- Returns:
- this / self
-
getBrowserExecutablePath
protected java.lang.String getBrowserExecutablePath()
-
setBrowserExecutablePath
public BrowserConfigurationOptions setBrowserExecutablePath(java.lang.String executablePath)
Sets the full path for the browser executable.- Parameters:
executablePath
- the full path for the browser executable.- Returns:
- this / self
-
setTimeoutInSeconds
public BrowserConfigurationOptions setTimeoutInSeconds(int timeout)
Sets the timeout, in seconds, for all commands.- Parameters:
timeout
- the timeout for all commands- Returns:
- this BrowserConfigurationOptions instance.
-
getTimeoutInSeconds
protected int getTimeoutInSeconds()
-
setBrowserMode
public BrowserConfigurationOptions setBrowserMode(java.lang.String mode)
Sets the "mode" for the browser. Historically, the 'browser' argument for getNewBrowserSession implied the mode for the browser. For example, *iehta indicated HTA mode for IE, whereas *iexplore indicated the default user mode. Using this method allows a browser mode to be specified independently of the base browser, eg. "HTA" or "PROXY". Note that absolutely no publication nor synchronization of these hard-coded strings such as "HTA" has yet been done. Use at your own risk until this is rectified.- Parameters:
mode
- - examples "HTA" or "PROXY"- Returns:
- this / self
-
getBrowserMode
protected java.lang.String getBrowserMode()
-
setCommandLineFlags
public BrowserConfigurationOptions setCommandLineFlags(java.lang.String cmdLineFlags)
-
getCommandLineFlags
public java.lang.String getCommandLineFlags()
-
canUse
protected boolean canUse(java.lang.String value)
-
isSet
public boolean isSet(java.lang.String key)
-
get
public java.lang.String get(java.lang.String key)
-
set
public BrowserConfigurationOptions set(java.lang.String key, java.lang.String value)
Sets the given key to the given value unless the value is null. In that case, no entry for the key is made.- Parameters:
key
- the name of the keyvalue
- the value for the key- Returns:
- this / self
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Returns:
- the serialization of this object, as defined by the serialize() method.
-
-