Package com.thoughtworks.selenium
Class BrowserConfigurationOptions
- java.lang.Object
-
- com.thoughtworks.selenium.BrowserConfigurationOptions
-
public class BrowserConfigurationOptions extends java.lang.ObjectContains 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.StringBROWSER_EXECUTABLE_PATHstatic java.lang.StringBROWSER_MODEstatic java.lang.StringCOMMAND_LINE_FLAGSstatic intDEFAULT_TIMEOUT_IN_SECONDSstatic java.lang.StringMULTI_WINDOWstatic java.lang.StringPROFILE_NAMEstatic java.lang.StringPROXY_CONFIGstatic java.lang.StringSINGLE_WINDOWstatic java.lang.StringTIMEOUT_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 booleancanUse(java.lang.String value)java.lang.Stringget(java.lang.String key)protected java.lang.StringgetBrowserExecutablePath()protected java.lang.StringgetBrowserMode()java.lang.StringgetCommandLineFlags()protected java.lang.StringgetProfile()protected intgetTimeoutInSeconds()booleanhasOptions()Returns true if any options are set in this instance.protected booleanisMultiWindow()Returns true if theMULTI_WINDOWfield is set.booleanisSet(java.lang.String key)protected booleanisSingleWindow()Returns true if theSINGLE_WINDOWfield is set.java.lang.Stringserialize()Serializes to the format "name=value;name=value".BrowserConfigurationOptionsset(java.lang.String key, java.lang.String value)Sets the given key to the given value unless the value is null.BrowserConfigurationOptionssetBrowserExecutablePath(java.lang.String executablePath)Sets the full path for the browser executable.BrowserConfigurationOptionssetBrowserMode(java.lang.String mode)Sets the "mode" for the browser.BrowserConfigurationOptionssetCommandLineFlags(java.lang.String cmdLineFlags)BrowserConfigurationOptionssetMultiWindow()SetsMULTI_WINDOWand unsetsSINGLE_WINDOWBrowserConfigurationOptionssetProfile(java.lang.String profile)Sets the name of the profile, which must exist in the -profilesLocation directory, to use for this browser session.BrowserConfigurationOptionssetSingleWindow()SetsSINGLE_WINDOWand unsetsMULTI_WINDOW.BrowserConfigurationOptionssetTimeoutInSeconds(int timeout)Sets the timeout, in seconds, for all commands.java.lang.StringtoString()
-
-
-
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_WINDOWfield is set.- Returns:
- true if
SINGLE_WINDOWis set.
-
isMultiWindow
protected boolean isMultiWindow()
Returns true if theMULTI_WINDOWfield is set.- Returns:
- true if
MULTI_WINDOWis set.
-
setSingleWindow
public BrowserConfigurationOptions setSingleWindow()
SetsSINGLE_WINDOWand unsetsMULTI_WINDOW.- Returns:
- this / self
-
setMultiWindow
public BrowserConfigurationOptions setMultiWindow()
SetsMULTI_WINDOWand 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:
toStringin classjava.lang.Object- Returns:
- the serialization of this object, as defined by the serialize() method.
-
-