Safe Haskell | Safe-Infered |
---|
This module serves as the top-level interface to the Haskell WebDriver bindings, providing most of the functionality you're likely to want.
- newtype WD a = WD (StateT WDSession IO a)
- data WDSession = WDSession {}
- defaultSession :: WDSession
- newtype SessionId = SessionId Text
- runWD :: WDSession -> WD a -> IO a
- runSession :: WDSession -> Capabilities -> WD a -> IO a
- withSession :: WDSession -> WD a -> WD a
- finallyClose :: WD a -> WD a
- closeOnException :: WD a -> WD a
- data Capabilities = Capabilities {
- browser :: Browser
- version :: Maybe String
- platform :: Platform
- proxy :: ProxyType
- javascriptEnabled :: Maybe Bool
- takesScreenshot :: Maybe Bool
- handlesAlerts :: Maybe Bool
- databaseEnabled :: Maybe Bool
- locationContextEnabled :: Maybe Bool
- applicationCacheEnabled :: Maybe Bool
- browserConnectionEnabled :: Maybe Bool
- cssSelectorsEnabled :: Maybe Bool
- webStorageEnabled :: Maybe Bool
- rotatable :: Maybe Bool
- acceptSSLCerts :: Maybe Bool
- nativeEvents :: Maybe Bool
- defaultCaps :: Capabilities
- allCaps :: Capabilities
- data Platform
- data ProxyType
- = NoProxy
- | UseSystemSettings
- | AutoDetect
- | PAC { }
- | Manual { }
- data Browser
- firefox :: Browser
- chrome :: Browser
- ie :: Browser
- opera :: Browser
- iPhone :: Browser
- iPad :: Browser
- android :: Browser
- module Test.WebDriver.Commands
- newtype InvalidURL = InvalidURL String
- newtype NoSessionId = NoSessionId String
- newtype BadJSON = BadJSON String
- data HTTPStatusUnknown = HTTPStatusUnknown (Int, Int, Int) String
- newtype HTTPConnError = HTTPConnError ConnError
- newtype UnknownCommand = UnknownCommand String
- newtype ServerError = ServerError String
- data FailedCommand = FailedCommand FailedCommandType FailedCommandInfo
- data FailedCommandType
- = NoSuchElement
- | NoSuchFrame
- | UnknownFrame
- | StaleElementReference
- | ElementNotVisible
- | InvalidElementState
- | UnknownError
- | ElementIsNotSelectable
- | JavascriptError
- | XPathLookupError
- | Timeout
- | NoSuchWindow
- | InvalidCookieDomain
- | UnableToSetCookie
- | UnexpectedAlertOpen
- | NoAlertOpen
- | ScriptTimeout
- | InvalidElementCoordinates
- | IMENotAvailable
- | IMEEngineActivationFailed
- | InvalidSelector
- | MoveTargetOutOfBounds
- | InvalidXPathSelector
- | InvalidXPathSelectorReturnType
- | MethodNotAllowed
- data FailedCommandInfo = FailedCommandInfo {}
- data StackFrame = StackFrame {}
- mkFailedCommandInfo :: String -> FailedCommandInfo
- failedCommand :: FailedCommandType -> String -> WD a
WebDriver sessions
A monadic interface to the WebDriver server. This monad is a simple, strict
wrapper over IO
, threading session information between sequential commands
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.
WDSession | |
|
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.
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.
Running WebDriver tests
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
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.
Capabilities | |
|
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).
Same as defaultCaps
, but with all Maybe Bool capabilities set to
Just True.
Represents platform options supported by WebDriver. The value Any represents no preference.
Available settings for the proxy Capabilities
field
NoProxy | |
UseSystemSettings | |
AutoDetect | |
PAC | Use a proxy auto-config file specified by URL |
Manual | Manually specify proxy hosts as hostname:port strings. Note that behavior is undefined for empty strings. |
Browser-specific configuration
Browser setting and browser-specific capabilities.
Firefox | |
Chrome | |
| |
IE | |
Opera | Opera-specific configuration coming soon! |
HTMLUnit | |
IPhone | |
IPad | |
Android |
Default Chrome settings. All Maybe fields are set to Nothing, no options are specified, and no extensions are used.
Default IE settings. ignoreProtectedModeSettings
is set to True.
WebDriver commands
module Test.WebDriver.Commands
Exceptions
newtype InvalidURL Source
An invalid URL was given
newtype NoSessionId Source
A command requiring a session ID was attempted when no session ID was available.
An error occured when parsing a JSON value.
data HTTPStatusUnknown Source
An unexpected HTTP status was sent by the server.
HTTPStatusUnknown (Int, Int, Int) String |
newtype HTTPConnError Source
HTTP connection errors.
newtype UnknownCommand Source
A command was sent to the WebDriver server that it didn't recognize.
newtype ServerError Source
A server-side exception occured
data FailedCommand Source
This exception encapsulates many different kinds of exceptions that can occur when a command fails.
data FailedCommandType Source
The type of failed command exception that occured.
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.
StackFrame | |
|
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.