com.thoughtworks.selenium
Class BrowserConfigurationOptions

java.lang.Object
  extended by 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 to Selenium.start(). The parameters set within will override any command-line parameters set for the same option.

Author:
jbevan, chandrap

Field Summary
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
BrowserConfigurationOptions()
          Instantiate a blank BrowserConfigurationOptions instance.
 
Method Summary
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 the MULTI_WINDOW field is set.
 boolean isSet(java.lang.String key)
           
protected  boolean isSingleWindow()
          Returns true if the SINGLE_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()
          Sets MULTI_WINDOW and unsets SINGLE_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()
          Sets SINGLE_WINDOW and unsets MULTI_WINDOW.
 BrowserConfigurationOptions setTimeoutInSeconds(int timeout)
          Sets the timeout, in seconds, for all commands.
 java.lang.String toString()
          Returns the serialization of this object, as defined by the serialize() method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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
Constructor Detail

BrowserConfigurationOptions

public BrowserConfigurationOptions()
Instantiate a blank BrowserConfigurationOptions instance.

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 the SINGLE_WINDOW field is set.

Returns:
true if SINGLE_WINDOW is set.

isMultiWindow

protected boolean isMultiWindow()
Returns true if the MULTI_WINDOW field is set.

Returns:
true if MULTI_WINDOW is set.

setSingleWindow

public BrowserConfigurationOptions setSingleWindow()
Sets SINGLE_WINDOW and unsets MULTI_WINDOW.


setMultiWindow

public BrowserConfigurationOptions setMultiWindow()
Sets MULTI_WINDOW and unsets SINGLE_WINDOW


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.

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 -

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 key
value - the value for the key

toString

public java.lang.String toString()
Returns the serialization of this object, as defined by the serialize() method.

Overrides:
toString in class java.lang.Object


Copyright © 2011. All Rights Reserved.