Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module serves as the top-level interface to the Haskell WebDriver bindings, providing most of the functionality you're likely to want.
Synopsis
- newtype WD a = WD (StateT WDSession IO a)
- runSession :: WebDriverConfig conf => conf -> WD a -> IO a
- withSession :: WDSessionStateControl m => WDSession -> m a -> m a
- runWD :: WDSession -> WD a -> IO a
- data WDConfig = WDConfig {}
- defaultConfig :: WDConfig
- useBrowser :: HasCapabilities t => Browser -> t -> t
- useProxy :: HasCapabilities t => ProxyType -> t -> t
- useVersion :: HasCapabilities t => String -> t -> t
- usePlatform :: HasCapabilities t => Platform -> t -> t
- type SessionHistoryConfig = SessionHistory -> [SessionHistory] -> [SessionHistory]
- noHistory :: SessionHistoryConfig
- unlimitedHistory :: SessionHistoryConfig
- onlyMostRecentHistory :: SessionHistoryConfig
- withRequestHeaders :: WDSessionStateControl m => RequestHeaders -> m a -> m a
- withAuthHeaders :: WDSessionStateControl m => m a -> m a
- module Test.WebDriver.Commands
- 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
- unexpectedAlertBehavior :: Maybe UnexpectedAlertBehavior
- additionalCaps :: [Pair]
- defaultCaps :: Capabilities
- allCaps :: Capabilities
- modifyCaps :: HasCapabilities t => (Capabilities -> Capabilities) -> t -> t
- data Platform
- data ProxyType
- = NoProxy
- | UseSystemSettings
- | AutoDetect
- | PAC { }
- | Manual { }
- data Browser
- = Firefox { }
- | Chrome { }
- | IE {
- ieIgnoreProtectedModeSettings :: Bool
- ieIgnoreZoomSetting :: Bool
- ieInitialBrowserUrl :: Maybe Text
- ieElementScrollBehavior :: IEElementScrollBehavior
- ieEnablePersistentHover :: Bool
- ieEnableElementCacheCleanup :: Bool
- ieRequireWindowFocus :: Bool
- ieBrowserAttachTimeout :: Integer
- ieLogFile :: Maybe FilePath
- ieLogLevel :: IELogLevel
- ieHost :: Maybe Text
- ieExtractPath :: Maybe Text
- ieSilent :: Bool
- ieForceCreateProcess :: Bool
- ieSwitches :: Maybe Text
- | Opera {
- operaBinary :: Maybe FilePath
- operaProduct :: Maybe String
- operaDetach :: Bool
- operaAutoStart :: Bool
- operaIdle :: Bool
- operaDisplay :: Maybe Int
- operaLauncher :: Maybe FilePath
- operaPort :: Maybe Word16
- operaHost :: Maybe String
- operaOptions :: Maybe String
- operaLogFile :: Maybe FilePath
- operaLogPref :: LogLevel
- | Phantomjs { }
- | HTMLUnit
- | IPhone
- | IPad
- | Android
- | Browser Text
- data LogLevel
- firefox :: Browser
- chrome :: Browser
- ie :: Browser
- opera :: Browser
- iPhone :: Browser
- iPad :: Browser
- android :: Browser
- finallyClose :: WebDriver wd => wd a -> wd a
- closeOnException :: WebDriver wd => wd a -> wd a
- module Test.WebDriver.Exceptions
- data SessionHistory = SessionHistory {}
- getSessionHistory :: WDSessionState wd => wd [SessionHistory]
- dumpSessionHistory :: WDSessionStateControl wd => wd a -> wd a
WebDriver monad
A state monad for WebDriver commands.
Instances
MonadFix WD Source # | |
Defined in Test.WebDriver.Monad | |
MonadIO WD Source # | |
Defined in Test.WebDriver.Monad | |
Applicative WD Source # | |
Functor WD Source # | |
Monad WD Source # | |
MonadCatch WD Source # | |
MonadMask WD Source # | |
MonadThrow WD Source # | |
Defined in Test.WebDriver.Monad | |
WebDriver WD Source # | |
Defined in Test.WebDriver.Monad | |
WDSessionState WD Source # | |
Defined in Test.WebDriver.Monad getSession :: WD WDSession Source # putSession :: WDSession -> WD () Source # | |
MonadBaseControl IO WD Source # | |
MonadBase IO WD Source # | |
Defined in Test.WebDriver.Monad | |
type StM WD a Source # | |
Running WebDriver commands
runSession :: WebDriverConfig conf => conf -> WD a -> IO a Source #
Executes a WD
computation within the IO
monad, automatically creating a new session beforehand.
NOTE: session is not automatically closed when complete. If you want this behavior, use finallyClose
.
Example:
runSessionThenClose action = runSession myConfig . finallyClose $ action
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 configuration
WebDriver session configuration
WDConfig | |
|
Instances
Default WDConfig Source # | |
Defined in Test.WebDriver.Config | |
GetCapabilities WDConfig Source # | |
Defined in Test.WebDriver.Config getCaps :: WDConfig -> Capabilities Source # | |
SetCapabilities WDConfig Source # | |
Defined in Test.WebDriver.Config | |
WebDriverConfig WDConfig Source # | |
defaultConfig :: WDConfig Source #
A default session config 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.
Configuration helper functions
Instead of working with the Capabilities
record directly, you can use
these config modifier functions to specify common options.
useBrowser :: HasCapabilities t => Browser -> t -> t Source #
A helper function for setting the browser
capability of a HasCapabilities
instance
useProxy :: HasCapabilities t => ProxyType -> t -> t Source #
A helper function for setting the useProxy
capability of a HasCapabilities
instance
useVersion :: HasCapabilities t => String -> t -> t Source #
A helper function for setting the version
capability of a HasCapabilities
instance
usePlatform :: HasCapabilities t => Platform -> t -> t Source #
A helper function for setting the platform
capability of a HasCapabilities
instance
Session history configuration
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.
unlimitedHistory :: SessionHistoryConfig Source #
Keep unlimited history
onlyMostRecentHistory :: SessionHistoryConfig Source #
Saves only the most recent history
HTTP request header utilities
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.
WebDriver commands
module Test.WebDriver.Commands
Capabilities (advanced 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.
Capabilities | |
|
Instances
FromJSON Capabilities Source # | |
Defined in Test.WebDriver.Capabilities parseJSON :: Value -> Parser Capabilities # parseJSONList :: Value -> Parser [Capabilities] # | |
ToJSON Capabilities Source # | |
Defined in Test.WebDriver.Capabilities toJSON :: Capabilities -> Value # toEncoding :: Capabilities -> Encoding # toJSONList :: [Capabilities] -> Value # toEncodingList :: [Capabilities] -> Encoding # | |
Show Capabilities Source # | |
Defined in Test.WebDriver.Capabilities showsPrec :: Int -> Capabilities -> ShowS # show :: Capabilities -> String # showList :: [Capabilities] -> ShowS # | |
Default Capabilities Source # | |
Defined in Test.WebDriver.Capabilities def :: Capabilities # | |
Eq Capabilities Source # | |
Defined in Test.WebDriver.Capabilities (==) :: Capabilities -> Capabilities -> Bool # (/=) :: Capabilities -> Capabilities -> Bool # | |
GetCapabilities Capabilities Source # | |
Defined in Test.WebDriver.Capabilities getCaps :: Capabilities -> Capabilities Source # |
allCaps :: Capabilities Source #
Same as defaultCaps
, but with all Maybe
Value
capabilities set to
Just
True
.
modifyCaps :: HasCapabilities t => (Capabilities -> Capabilities) -> t -> t Source #
Modifies the wdCapabilities
field of a WDConfig
by applying the given function. Overloaded to work with any HasCapabilities
instance.
Represents platform options supported by WebDriver. The value Any represents no preference.
Instances
FromJSON Platform Source # | |
ToJSON Platform Source # | |
Defined in Test.WebDriver.Capabilities | |
Bounded Platform Source # | |
Enum Platform Source # | |
Defined in Test.WebDriver.Capabilities | |
Show Platform Source # | |
Eq Platform Source # | |
Ord Platform Source # | |
Defined in Test.WebDriver.Capabilities |
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 capabilities
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.
Firefox | |
| |
Chrome | |
| |
IE | |
| |
Opera | |
| |
Phantomjs | |
HTMLUnit | |
IPhone | |
IPad | |
Android | |
Browser Text | some other browser, specified by a string name |
Instances
FromJSON LogLevel Source # | |
ToJSON LogLevel Source # | |
Defined in Test.WebDriver.Capabilities | |
Bounded LogLevel Source # | |
Enum LogLevel Source # | |
Defined in Test.WebDriver.Capabilities | |
Read LogLevel Source # | |
Show LogLevel Source # | |
Default LogLevel Source # | |
Defined in Test.WebDriver.Capabilities | |
Eq LogLevel Source # | |
Ord LogLevel Source # | |
Defined in Test.WebDriver.Capabilities |
Browser defaults
Default Firefox settings. All Maybe fields are set to Nothing. ffLogPref
is set to LogInfo
.
Default Chrome settings. All Maybe fields are set to Nothing, no options are specified, and no extensions are used.
Default IE settings. See the IE
constructor for more details on
individual defaults
Default Opera settings. See the Opera
constructor for more details on
individual defaults.
Exception handling
finallyClose :: WebDriver wd => wd a -> wd a Source #
A finalizer ensuring that the session is always closed at the end of
the given WD
action, regardless of any exceptions.
closeOnException :: WebDriver wd => wd a -> wd a Source #
Exception handler that closes the session when an asynchronous exception is thrown, but otherwise leaves the session open if the action was successful.
module Test.WebDriver.Exceptions
Accessing session history
data SessionHistory Source #
Instances
Show SessionHistory Source # | |
Defined in Test.WebDriver.Session.History showsPrec :: Int -> SessionHistory -> ShowS # show :: SessionHistory -> String # showList :: [SessionHistory] -> ShowS # |
getSessionHistory :: WDSessionState wd => wd [SessionHistory] Source #
Gets the command history for the current session.
dumpSessionHistory :: WDSessionStateControl wd => wd a -> wd a Source #
Prints a history of API requests to stdout after computing the given action.