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

Safe HaskellNone
LanguageHaskell2010

Test.WebDriver.Session

Contents

Synopsis

WDSessionState class

class (Monad m, Applicative m) => WDSessionState m where Source

A class for monads that carry a WebDriver session with them. The MonadBaseControl superclass is used for exception handling through the lifted-base package.

Methods

getSession :: m WDSession Source

Retrieves the current session state of the monad

putSession :: WDSession -> m () Source

Sets a new session state for the monad

type WDSessionStateIO s = (WDSessionState s, MonadBase IO s) Source

Constraint synonym for the common pairing of WDSessionState and MonadBase IO.

type WDSessionStateControl s = (WDSessionState s, MonadBaseControl IO s) Source

Constraint synonym for another common pairing of WDSessionState and MonadBaseControl IO. This is commonly used in library types to indicate use of lifted exception handling.

withSession :: WDSessionStateControl m => WDSession -> m a -> m a Source

Locally sets a session state for use within the given action. The state of any outside action is unaffected by this function. This function is useful if you need to work with multiple sessions simultaneously.

WebDriver sessions

data WDSession Source

The local state of a WebDriver session. This structure is passed implicitly through all WD computations

Constructors

WDSession 

Fields

wdSessHost :: ByteString
 
wdSessPort :: Int
 
wdSessBasePath :: ByteString
 
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 automatically with runSession

wdSessHist :: [SessionHistory]

The complete history of HTTP requests and responses, most recent first.

wdSessHistUpdate :: SessionHistoryConfig

Update function used to append new entries to session history

wdSessHTTPManager :: Manager

HTTP Manager used for connection pooling by the http-client library.

wdSessHTTPRetryCount :: Int

Number of times to retry a HTTP request if it times out

wdSessRequestHeaders :: RequestHeaders

Custom request headers to add to every HTTP request.

wdSessAuthHeaders :: RequestHeaders

Custom request headers to add *only* to session creation requests. This is usually done when a WebDriver server requires HTTP auth.

mostRecentHistory :: WDSession -> Maybe SessionHistory Source

The most recent SessionHistory entry recorded by this session, if any.

mostRecentHTTPRequest :: WDSession -> Maybe Request Source

The most recent HTTP request issued by this session, if any.

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 

SessionHistoryConfig options

type SessionHistoryConfig = SessionHistory -> [SessionHistory] -> [SessionHistory] Source

A function used by wdHistoryConfig to append new entries to session history.

noHistory :: SessionHistoryConfig Source

No session history is saved.

onlyMostRecentHistory :: SessionHistoryConfig Source

Saves only the most recent history

Using custom HTTP request headers

withRequestHeaders :: WDSessionStateControl m => RequestHeaders -> m a -> m a Source

Set a temporary list of custom RequestHeaders to use within the given action. All previous custom headers are temporarily removed, and then restored at the end.

withAuthHeaders :: WDSessionStateControl m => m a -> m a Source

Makes all webdriver HTTP requests in the given action use the session's auth headers, typically configured by setting the wdAuthHeaders config. This is useful if you want to temporarily use the same auth headers you used for session creation with other HTTP requests.