webdriver-0.1: 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 wrapper 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. A value of Nothing indicates that a session hasn't been created yet. To create new sessions, use the createSession and runSession functions.

defaultSession :: WDSessionSource

A default session connects to localhost on port 4444, and hasn't been created yet. This value is the same as def but with a more specific 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 returned by getCaps, 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.



defaultCaps :: CapabilitiesSource

Default capabilities. This is the same as the Default instance, but with a more specific type. By default we use Firefox of an unspecified version with default 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

Browser setting and browser-specific capabilities.




ffProfile :: Maybe PreparedFirefoxProfile

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

ffLogPref :: Maybe FFLogPref

Firefox logging preference

ffBinary :: Maybe FilePath

Path to Firefox binary. If Nothing, use a sensible system-based default.



chromeDriverVersion :: Maybe String
chromeBinary :: Maybe FilePath

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.


Opera-specific configuration coming soon!


firefox :: BrowserSource

Default Firefox settings. All fields are set to Nothing.

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.

WebDriver commands


newtype InvalidURL Source

An invalid URL was given


InvalidURL String 

newtype NoSessionId Source

A command requiring a session ID was attempted when no session ID was available.


NoSessionId String 

newtype BadJSON Source

An error occured when parsing a JSON value.


BadJSON String 

data HTTPStatusUnknown Source

An unexpected HTTP status was sent by the server.


HTTPStatusUnknown (Int, Int, Int) String 

newtype UnknownCommand Source

A command was sent to the WebDriver server that it didn't recognize.


UnknownCommand String 

newtype ServerError Source

A server-side exception occured


ServerError String 

data FailedCommand Source

This exception encapsulates many different kinds of exceptions that can occur when a command fails.

data FailedCommandInfo Source

Detailed information about the failed command provided by the server.

data StackFrame Source

An individual stack frame from the stack trace provided by the server during a FailedCommand.

mkFailedCommandInfo :: String -> FailedCommandInfoSource

Constructs a FailedCommandInfo from only an error message.

failedCommand :: FailedCommandType -> String -> WD aSource

Convenience function to throw a FailedCommand locally with no server-side info present.