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

Safe HaskellNone

Test.WebDriver.Types

Contents

Synopsis

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

Constructors

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.

Constructors

WDSession 

Fields

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 the createSession, or created and closed automatically with runSession

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.

Constructors

SessionId Text 

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.

Constructors

Capabilities 

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.

Constructors

Windows 
XP 
Vista 
Mac 
Linux 
Unix 
Any 

data ProxyType Source

Available settings for the proxy Capabilities field

Constructors

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

data Browser Source

Browser setting and browser-specific capabilities.

Constructors

Firefox 

Fields

ffProfile :: Maybe PreparedFirefoxProfile

The firefox profile to use. If Nothing, 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.

Chrome 

Fields

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

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.

IE 
Opera

(Opera-specific configuration coming soon!)

HTMLUnit 
IPhone 
IPad 
Android 

Default settings for browsers

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.

data FFLogPref Source

For Firefox sessions; indicates Firefox's log level

WebDriver objects and command-specific types

newtype Element Source

An opaque identifier for a web page element.

Constructors

Element Text 

newtype WindowHandle Source

An opaque identifier for a browser window

Constructors

WindowHandle Text 

currentWindow :: WindowHandleSource

A special WindowHandle that always refers to the currently focused window.

data Selector Source

Specifies element(s) within a DOM tree using various selection methods.

Constructors

ById Text 
ByName Text 
ByClass Text

(Note: multiple classes are not allowed. For more control, use ByCSS)

ByTag Text 
ByLinkText Text 
ByPartialLinkText Text 
ByCSS Text 
ByXPath Text 

data JSArg Source

An existential wrapper for any ToJSON instance. This allows us to pass parameters of many different types to Javascript code.

Constructors

forall a . ToJSON a => JSArg a 

Instances

data FrameSelector Source

Specifies the frame used by focusFrame

Constructors

WithIndex Integer 
WithName Text

focus on a frame by name or ID

WithElement Element

focus on a frame Element

DefaultFrame

focus on the first frame, or the main document if iframes are used.

data Cookie Source

Cookies are delicious delicacies. When sending cookies to the server, a value of Nothing indicates that the server should use a default value. When receiving cookies from the server, a value of Nothing indicates that the server is unable to specify the value.

Constructors

Cookie 

Fields

cookName :: Text
 
cookValue :: Text
 
cookPath :: Maybe Text

path of this cookie. if Nothing, defaults to /

cookDomain :: Maybe Text

domain of this cookie. if Nothing, the current pages domain is used

cookSecure :: Maybe Bool

Is this cookie secure?

cookExpiry :: Maybe Integer

Expiry date expressed as seconds since the Unix epoch Nothing indicates that the cookie never expires

mkCookie :: Text -> Text -> CookieSource

Creates a Cookie with only a name and value specified. All other fields are set to Nothing, which tells the server to use default values.

Exceptions

newtype InvalidURL Source

An invalid URL was given

Constructors

InvalidURL String 

newtype NoSessionId Source

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

Constructors

NoSessionId String 

newtype BadJSON Source

An error occured when parsing a JSON value.

Constructors

BadJSON String 

data HTTPStatusUnknown Source

An unexpected HTTP status was sent by the server.

Constructors

HTTPStatusUnknown (Int, Int, Int) String 

newtype UnknownCommand Source

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

Constructors

UnknownCommand String 

newtype ServerError Source

A server-side exception occured

Constructors

ServerError String 

data FailedCommand Source

This exception encapsulates a broad variety of exceptions that can occur when a command fails.

data FailedCommandInfo Source

Detailed information about the failed command provided by the server.

Constructors

FailedCommandInfo 

Fields

errMsg :: String

The error message.

errSess :: WDSession

The session associated with the exception.

errScreen :: Maybe ByteString

A screen shot of the focused window when the exception occured, if provided.

errClass :: Maybe String

The class in which the exception was raised, if provided.

errStack :: [StackFrame]

A stack trace of the exception.

data StackFrame Source

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

mkFailedCommandInfo :: String -> WD 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.