webdriver-0.3.2: a Haskell client for the Selenium WebDriver protocol

Safe HaskellSafe-Infered




This module serves as the top-level interface to the Haskell WebDriver bindings, providing most of the functionality you're likely to want.


WebDriver sessions

newtype WD a Source

A monadic interface to the WebDriver server. This monad is a simple, strict layer over IO, threading session information between sequential commands


WD (StateT WDSession IO a) 

data WDSession Source

Information about a WebDriver session. This structure is passed implicitly through all WD computations, and is also used to configure the WD monad before execution.




wdHost :: String

Host name of the WebDriver server for this session

wdPort :: Word16

Port number of the server

wdSessId :: Maybe SessionId

An opaque reference identifying the session to use with WD commands. A value of Nothing indicates that a session hasn't been created yet. Sessions can be created within WD via createSession, or created and closed automatically with runSession

defaultSession :: WDSessionSource

A default session connects to localhost on port 4444, and hasn't been initialized server-side. This value is the same as def but with a less polymorphic type.

newtype SessionId Source

An opaque identifier for a WebDriver session. These handles are produced by the server on session creation, and act to identify a session in progress.


SessionId Text 

Running WebDriver tests

runWD :: WDSession -> WD a -> IO aSource

Executes a WD computation within the IO monad, using the given WDSession.

runSession :: WDSession -> Capabilities -> WD a -> IO aSource

Like runWD, but automatically creates a session beforehand and closes it afterwards. This is a very common use case.

withSession :: WDSession -> WD a -> WD aSource

Locally sets a WDSession for use within the given WD action. The state of the outer action is unaffected by this function. This function is useful if you need to work with multiple sessions at once.

finallyClose :: WD a -> WD aSource

A finalizer ensuring that the session is always closed at the end of the given WD action, regardless of any exceptions.

closeOnException :: WD a -> WD aSource

A variant of finallyClose that only closes the session when an asynchronous exception is thrown, but otherwise leaves the session open if the action was successful.

Capabilities and configuration

data Capabilities Source

A structure describing the capabilities of a session. This record serves dual roles.

  • It's used to specify the desired capabilities for a session before it's created. In this usage, fields that are set to Nothing indicate that we have no preference for that capability.
  • When received from the server , it's used to describe the actual capabilities given to us by the WebDriver server. Here a value of Nothing indicates that the server doesn't support the capability. Thus, for Maybe Bool fields, both Nothing and Just False indicate a lack of support for the desired capability.




browser :: Browser

Browser choice and browser specific settings.

version :: Maybe String

Browser version to use.

platform :: Platform

Platform on which the browser should run.

proxy :: ProxyType

Proxy configuration settings.

javascriptEnabled :: Maybe Bool

Whether the session supports executing JavaScript via executeJS and asyncJS.

takesScreenshot :: Maybe Bool

Whether the session supports taking screenshots of the current page with the screenshot command

handlesAlerts :: Maybe Bool

Whether the session can interact with modal popups, such as window.alert and window.confirm via acceptAlerts, dismissAlerts, etc.

databaseEnabled :: Maybe Bool

Whether the session can interact with database storage.

locationContextEnabled :: Maybe Bool

Whether the session can set and query the browser's location context with setLocation and getLocation.

applicationCacheEnabled :: Maybe Bool

Whether the session can interact with the application cache .

browserConnectionEnabled :: Maybe Bool

Whether the session can query for the browser's connectivity and disable it if desired

cssSelectorsEnabled :: Maybe Bool

Whether the session supports CSS selectors when searching for elements.

webStorageEnabled :: Maybe Bool

Whether Web Storage (getKey, setKey, etc) support is enabled

rotatable :: Maybe Bool

Whether the session can rotate the current page's current layout between Portrait and Landscape orientations.

acceptSSLCerts :: Maybe Bool

Whether the session should accept all SSL certs by default

nativeEvents :: Maybe Bool

Whether the session is capable of generating native OS events when simulating user input.

defaultCaps :: CapabilitiesSource

Default capabilities. This is the same as the Default instance, but with less polymorphism. By default, we use firefox of an unspecified version with default system-wide proxy settings on whatever platform is available . All Maybe Bool capabilities are set to Nothing (no preference).

allCaps :: CapabilitiesSource

Same as defaultCaps, but with all Maybe Bool capabilities set to Just True.

data Platform Source

Represents platform options supported by WebDriver. The value Any represents no preference.



data ProxyType Source

Available settings for the proxy Capabilities field



Use a proxy auto-config file specified by URL


Manually specify proxy hosts as hostname:port strings. Note that behavior is undefined for empty strings.

Browser-specific configuration

data Browser Source

This constructor simultaneously specifies which browser the session will use, while also providing browser-specific configuration. Default configuration is provided for each browser by firefox, chrome, opera, ie, etc.

This library uses firefox as its Default browser configuration, when no browser choice is specified.




ffProfile :: Maybe (PreparedProfile Firefox)

The firefox profile to use. If Nothing, a default temporary profile is automatically created and used.

ffLogPref :: LogPref

Firefox logging preference

ffBinary :: Maybe FilePath

Server-side path to Firefox binary. If Nothing, use a sensible system-based default.



chromeDriverVersion :: Maybe String

Version of the Chrome Webdriver server server to use

for more information on chromedriver see http://code.google.com/p/selenium/wiki/ChromeDriver

chromeBinary :: Maybe FilePath

Server-side path to Chrome binary. If Nothing, use a sensible system-based default.

chromeOptions :: [String]

A list of command-line options to pass to the Chrome binary.

chromeExtensions :: [ChromeExtension]

A list of extensions to use.



ignoreProtectedModeSettings :: Bool

Whether to skip the protected mode check. If set, tests may become flaky, unresponsive, or browsers may hang. If not set, and protected mode settings are not the same for all zones, an exception will be thrown on driver construction.



operaBinary :: Maybe FilePath

Server-side path to the Opera binary

operaProduct :: Maybe String

Which Opera product we're using, e.g. "desktop", "core"

operaDetach :: Bool

Whether the Opera instance should stay open after we close the session. If false, closing the session closes the browser.

operaAutoStart :: Bool

Whether to auto-start the Opera binary. If false, OperaDriver will wait for a connection from the browser. By default this is True.

operaIdle :: Bool

Whether to use Opera's alternative implicit wait implementation. It will use an in-browser heuristic to guess when a page has finished loading. This feature is experimental, and disabled by default.

operaDisplay :: Maybe Int

(*nix only) which X display to use.

operaLauncher :: Maybe FilePath

Path to the launcher binary to use. The launcher is a gateway between OperaDriver and the Opera browser. If Nothing, OperaDriver will use the launcher supplied with the package.

operaPort :: Maybe Word16

The port we should use to connect to Opera. If Just 0 , use a random port. If Nothing, use the default Opera port. The default opera constructor uses Just 0, since Nothing is likely to cause address already in use errors.

operaHost :: Maybe String

The host Opera should connect to. Unless you're starting Opera manually you won't need this.

operaOptions :: String

Command-line arguments to pass to Opera.

operaLogFile :: Maybe FilePath

Where to send the log output. If Nothing, logging is disabled.

operaLogPref :: LogPref

Log level preference. Defaults to LogInfo


firefox :: BrowserSource

Default Firefox settings. All Maybe fields are set to Nothing. ffLogPref is set to LogInfo.

chrome :: BrowserSource

Default Chrome settings. All Maybe fields are set to Nothing, no options are specified, and no extensions are used.

ie :: BrowserSource

Default IE settings. ignoreProtectedModeSettings is set to True.

opera :: BrowserSource

Default Opera settings. See the Opera constructor for more details on individual defaults.

WebDriver commands