-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | a Haskell client for the Selenium WebDriver protocol -- @package webdriver @version 0.6.2 -- | Functions and types for working with Google Chrome extensions. module Test.WebDriver.Chrome.Extension -- | An opaque type representing a Google Chrome extension. Values of this -- type are passed to the chromeExtensions field. data ChromeExtension -- | Load a .crx file as a ChromeExtension. loadExtension :: MonadBase IO m => FilePath -> m ChromeExtension -- | Load raw .crx data as a ChromeExtension. loadRawExtension :: ByteString -> ChromeExtension instance Eq ChromeExtension instance Show ChromeExtension instance Read ChromeExtension instance ToJSON ChromeExtension instance FromJSON ChromeExtension -- | A type for profile preferences. These preference values are used by -- both Firefox and Opera profiles. module Test.WebDriver.Common.Profile -- | This structure allows you to construct and manipulate profiles in pure -- code, deferring execution of IO operations until the profile is -- "prepared". This type is shared by both Firefox and Opera profiles; -- when a distinction must be made, the phantom type parameter is used to -- differentiate. data Profile b Profile :: HashMap FilePath FilePath -> HashMap Text ProfilePref -> Profile b -- | A mapping from relative destination filepaths to source filepaths -- found on the filesystem. When the profile is prepared, these source -- filepaths will be moved to their destinations within the profile -- directory. -- -- Using the destination path as the key ensures that there is one unique -- source path going to each destination path. profileFiles :: Profile b -> HashMap FilePath FilePath -- | A map of profile preferences. These are the settings found in the -- profile's prefs.js, and entries found in about:config profilePrefs :: Profile b -> HashMap Text ProfilePref -- | Represents a profile that has been prepared for network transmission. -- The profile cannot be modified in this form. newtype PreparedProfile b PreparedProfile :: ByteString -> PreparedProfile b -- | A profile preference value. This is the subset of JSON values that -- excludes arrays, objects, and null. data ProfilePref PrefInteger :: !Integer -> ProfilePref PrefDouble :: !Double -> ProfilePref PrefString :: !Text -> ProfilePref PrefBool :: !Bool -> ProfilePref -- | A typeclass to convert types to profile preference values class ToPref a toPref :: ToPref a => a -> ProfilePref -- | Retrieve a preference from a profile by key name. getPref :: Text -> Profile b -> Maybe ProfilePref -- | Add a new preference entry to a profile, overwriting any existing -- entry with the same key. addPref :: ToPref a => Text -> a -> Profile b -> Profile b -- | Delete an existing preference entry from a profile. This operation is -- silent if the preference wasn't found. deletePref :: Text -> Profile b -> Profile b -- | Add a new extension to the profile. The file path should refer to a -- .xpi file or an extension directory on the filesystem. addExtension :: FilePath -> Profile b -> Profile b -- | Delete an existing extension from the profile. The string parameter -- should refer to an .xpi file or directory located within the -- extensions directory of the profile. This operation has no effect if -- the extension was never added to the profile. deleteExtension :: String -> Profile b -> Profile b -- | Determines if a profile contains the given extension. specified as an -- .xpi file or directory name hasExtension :: String -> Profile b -> Bool -- | Add a file to the profile directory. The first argument is the source -- of the file on the local filesystem. The second argument is the -- destination as a path relative to a profile directory. Overwrites any -- file that previously pointed to the same destination addFile :: FilePath -> FilePath -> Profile b -> Profile b -- | Delete a file from the profile directory. The first argument is the -- name of file within the profile directory. deleteFile :: FilePath -> Profile b -> Profile b -- | Determines if a profile contains the given file, specified as a path -- relative to the profile directory. hasFile :: String -> Profile b -> Bool -- | Takes the union of two profiles. This is the union of their -- HashMap fields. unionProfiles :: Profile b -> Profile b -> Profile b -- | Modifies the profileFiles field of a profile onProfileFiles :: Profile b -> (HashMap FilePath FilePath -> HashMap FilePath FilePath) -> Profile b -- | Modifies the profilePrefs field of a profile. onProfilePrefs :: Profile b -> (HashMap Text ProfilePref -> HashMap Text ProfilePref) -> Profile b -- | Efficiently load an existing profile from disk and prepare it for -- network transmission. prepareLoadedProfile_ :: MonadBase IO m => FilePath -> m (PreparedProfile a) -- | Prepare a zip file of a profile on disk for network transmission. This -- function is very efficient at loading large profiles from disk. prepareZippedProfile :: MonadBase IO m => FilePath -> m (PreparedProfile a) -- | Prepare a zip archive of a profile for network transmission. prepareZipArchive :: Archive -> PreparedProfile a -- | Prepare a ByteString of raw zip data for network transmission prepareRawZip :: ByteString -> PreparedProfile a -- | An error occured while attempting to parse a profile's preference -- file. newtype ProfileParseError ProfileParseError :: String -> ProfileParseError instance Typeable ProfileParseError instance Eq (PreparedProfile b) instance Show (PreparedProfile b) instance Eq ProfilePref instance Show ProfilePref instance Eq (Profile b) instance Show (Profile b) instance Eq ProfileParseError instance Show ProfileParseError instance Read ProfileParseError instance HasResolution r => ToPref (Fixed r) instance Integral a => ToPref (Ratio a) instance ToPref Float instance ToPref Double instance ToPref Word64 instance ToPref Word32 instance ToPref Word16 instance ToPref Word8 instance ToPref Word instance ToPref Int64 instance ToPref Int32 instance ToPref Int16 instance ToPref Int8 instance ToPref Int instance ToPref Integer instance ToPref Bool instance ToPref String instance ToPref Text instance Exception ProfileParseError instance FromJSON ProfilePref instance ToJSON ProfilePref instance ToJSON (PreparedProfile s) instance FromJSON (PreparedProfile s) -- | A module for working with Firefox profiles. Firefox profiles are -- manipulated in pure code and then "prepared" for network transmission. module Test.WebDriver.Firefox.Profile -- | Phantom type used in the parameters of Profile and -- PreparedProfile data Firefox -- | This structure allows you to construct and manipulate profiles in pure -- code, deferring execution of IO operations until the profile is -- "prepared". This type is shared by both Firefox and Opera profiles; -- when a distinction must be made, the phantom type parameter is used to -- differentiate. data Profile b Profile :: HashMap FilePath FilePath -> HashMap Text ProfilePref -> Profile b -- | A mapping from relative destination filepaths to source filepaths -- found on the filesystem. When the profile is prepared, these source -- filepaths will be moved to their destinations within the profile -- directory. -- -- Using the destination path as the key ensures that there is one unique -- source path going to each destination path. profileFiles :: Profile b -> HashMap FilePath FilePath -- | A map of profile preferences. These are the settings found in the -- profile's prefs.js, and entries found in about:config profilePrefs :: Profile b -> HashMap Text ProfilePref -- | Represents a profile that has been prepared for network transmission. -- The profile cannot be modified in this form. data PreparedProfile b -- | Default Firefox Profile, used when no profile is supplied. defaultProfile :: Profile Firefox -- | A profile preference value. This is the subset of JSON values that -- excludes arrays, objects, and null. data ProfilePref PrefInteger :: !Integer -> ProfilePref PrefDouble :: !Double -> ProfilePref PrefString :: !Text -> ProfilePref PrefBool :: !Bool -> ProfilePref -- | A typeclass to convert types to profile preference values class ToPref a toPref :: ToPref a => a -> ProfilePref -- | Add a new preference entry to a profile, overwriting any existing -- entry with the same key. addPref :: ToPref a => Text -> a -> Profile b -> Profile b -- | Retrieve a preference from a profile by key name. getPref :: Text -> Profile b -> Maybe ProfilePref -- | Delete an existing preference entry from a profile. This operation is -- silent if the preference wasn't found. deletePref :: Text -> Profile b -> Profile b -- | Add a new extension to the profile. The file path should refer to a -- .xpi file or an extension directory on the filesystem. addExtension :: FilePath -> Profile b -> Profile b -- | Delete an existing extension from the profile. The string parameter -- should refer to an .xpi file or directory located within the -- extensions directory of the profile. This operation has no effect if -- the extension was never added to the profile. deleteExtension :: String -> Profile b -> Profile b -- | Determines if a profile contains the given extension. specified as an -- .xpi file or directory name hasExtension :: String -> Profile b -> Bool -- | Add a file to the profile directory. The first argument is the source -- of the file on the local filesystem. The second argument is the -- destination as a path relative to a profile directory. Overwrites any -- file that previously pointed to the same destination addFile :: FilePath -> FilePath -> Profile b -> Profile b -- | Delete a file from the profile directory. The first argument is the -- name of file within the profile directory. deleteFile :: FilePath -> Profile b -> Profile b -- | Determines if a profile contains the given file, specified as a path -- relative to the profile directory. hasFile :: String -> Profile b -> Bool -- | Takes the union of two profiles. This is the union of their -- HashMap fields. unionProfiles :: Profile b -> Profile b -> Profile b -- | Modifies the profileFiles field of a profile onProfileFiles :: Profile b -> (HashMap FilePath FilePath -> HashMap FilePath FilePath) -> Profile b -- | Modifies the profilePrefs field of a profile. onProfilePrefs :: Profile b -> (HashMap Text ProfilePref -> HashMap Text ProfilePref) -> Profile b -- | Prepare a firefox profile for network transmission. Internally, this -- function constructs a Firefox profile within a temp directory, -- archives it as a zip file, and then base64 encodes the zipped data. -- The temporary directory is deleted afterwards. -- -- NOTE: because this function has to copy the profile files into a a -- temp directory before zip archiving them, this operation is likely to -- be slow for large profiles. In such a case, consider using -- prepareLoadedProfile_ or prepareZippedProfile instead. prepareProfile :: MonadBaseControl IO m => Profile Firefox -> m (PreparedProfile Firefox) -- | Apply a function on a default profile, and prepare the result. The -- Profile passed to the handler function is the default profile used by -- sessions when Nothing is specified prepareTempProfile :: MonadBaseControl IO m => (Profile Firefox -> Profile Firefox) -> m (PreparedProfile Firefox) -- | Load an existing profile from the file system. Any prepared changes -- made to the Profile will have no effect to the profile on disk. -- -- To make automated browser run smoothly, preferences found in -- defaultProfile are automatically merged into the preferences of -- the on-disk-- profile. The on-disk profile's preference will override -- those found in the default profile. loadProfile :: MonadBaseControl IO m => FilePath -> m (Profile Firefox) -- | Convenience function to load an existing Firefox profile from disk, -- apply a handler function, and then prepare the result for network -- transmission. -- -- NOTE: like prepareProfile, the same caveat about large profiles -- applies. prepareLoadedProfile :: MonadBaseControl IO m => FilePath -> (Profile Firefox -> Profile Firefox) -> m (PreparedProfile Firefox) -- | Efficiently load an existing profile from disk and prepare it for -- network transmission. prepareLoadedProfile_ :: MonadBase IO m => FilePath -> m (PreparedProfile a) -- | Prepare a zip file of a profile on disk for network transmission. This -- function is very efficient at loading large profiles from disk. prepareZippedProfile :: MonadBase IO m => FilePath -> m (PreparedProfile a) -- | Prepare a zip archive of a profile for network transmission. prepareZipArchive :: Archive -> PreparedProfile a -- | Prepare a ByteString of raw zip data for network transmission prepareRawZip :: ByteString -> PreparedProfile a -- | An error occured while attempting to parse a profile's preference -- file. newtype ProfileParseError ProfileParseError :: String -> ProfileParseError module Test.WebDriver.Utils urlEncode :: Text -> Text -- | A collection of convenience functions for using and parsing JSON -- values within WD. All monadic parse errors are converted to -- asynchronous BadJSON exceptions. -- -- These functions are used internally to implement webdriver commands, -- and may be useful for implementing non-standard commands. module Test.WebDriver.JSON -- | This operator is a wrapper over Aeson's .: operator. (!:) :: (MonadBaseControl IO wd, FromJSON a) => Object -> Text -> wd a -- | Parse a lazy ByteString as a top-level JSON Value, then -- convert it to an instance of FromJSON.. parseJSON' :: MonadBaseControl IO wd => FromJSON a => ByteString -> wd a -- | Convert a JSON Value to an instance of FromJSON. fromJSON' :: MonadBaseControl IO wd => FromJSON a => Value -> wd a -- | Construct a singleton JSON object from a key and value. single :: ToJSON a => Text -> a -> Value -- | Construct a 2-element JSON object from a pair of keys and a -- pair of values. pair :: (ToJSON a, ToJSON b) => (Text, Text) -> (a, b) -> Value -- | Construct a 3-element JSON object from a triple of keys and a -- triple of values. triple :: (ToJSON a, ToJSON b, ToJSON c) => (Text, Text, Text) -> (a, b, c) -> Value -- | Parse a JSON Object as a pair. The first two string arguments -- specify the keys to extract from the object. The third string is the -- name of the calling function, for better error reporting. parsePair :: (MonadBaseControl IO wd, FromJSON a, FromJSON b) => String -> String -> String -> Value -> wd (a, b) -- | Parse a JSON Object as a triple. The first three string arguments -- specify the keys to extract from the object. The fourth string is the -- name of the calling function, for better error reporting. parseTriple :: (MonadBaseControl IO wd, FromJSON a, FromJSON b, FromJSON c) => String -> String -> String -> String -> Value -> wd (a, b, c) -- | Convert an attoparsec parser result to WD. apResultToWD :: (MonadBaseControl IO wd, FromJSON a) => Result Value -> wd a -- | Convert an Aeson parser result to WD. aesonResultToWD :: MonadBaseControl IO wd => Result a -> wd a -- | An error occured when parsing a JSON value. newtype BadJSON BadJSON :: String -> BadJSON -- | A type indicating that we expect no return value from the webdriver -- request. Its FromJSON instance parses successfully for any values that -- indicate lack of a return value (a notion that varies from server to -- server). data NoReturn NoReturn :: NoReturn instance Typeable BadJSON instance Eq BadJSON instance Show BadJSON instance FromJSON NoReturn instance Exception BadJSON module Test.WebDriver.Capabilities -- | A structure describing the capabilities of a session. This record -- serves dual roles. -- -- data Capabilities Capabilities :: Browser -> Maybe String -> Platform -> ProxyType -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe UnexpectedAlertBehavior -> [Pair] -> Capabilities -- | Browser choice and browser specific settings. browser :: Capabilities -> Browser -- | Browser version to use. version :: Capabilities -> Maybe String -- | Platform on which the browser should run. platform :: Capabilities -> Platform -- | Proxy configuration settings. proxy :: Capabilities -> ProxyType -- | Whether the session supports executing JavaScript via -- executeJS and asyncJS. javascriptEnabled :: Capabilities -> Maybe Bool -- | Whether the session supports taking screenshots of the current page -- with the screenshot command takesScreenshot :: Capabilities -> Maybe Bool -- | Whether the session can interact with modal popups, such as -- window.alert and window.confirm via acceptAlerts, -- dismissAlerts, etc. handlesAlerts :: Capabilities -> Maybe Bool -- | Whether the session can interact with database storage. databaseEnabled :: Capabilities -> Maybe Bool -- | Whether the session can set and query the browser's location context -- with setLocation and getLocation. locationContextEnabled :: Capabilities -> Maybe Bool -- | Whether the session can interact with the application cache . applicationCacheEnabled :: Capabilities -> Maybe Bool -- | Whether the session can query for the browser's connectivity and -- disable it if desired browserConnectionEnabled :: Capabilities -> Maybe Bool -- | Whether the session supports CSS selectors when searching for -- elements. cssSelectorsEnabled :: Capabilities -> Maybe Bool -- | Whether Web Storage (getKey, setKey, etc) support is -- enabled webStorageEnabled :: Capabilities -> Maybe Bool -- | Whether the session can rotate the current page's current layout -- between Portrait and Landscape orientations. rotatable :: Capabilities -> Maybe Bool -- | Whether the session should accept all SSL certs by default acceptSSLCerts :: Capabilities -> Maybe Bool -- | Whether the session is capable of generating native OS events when -- simulating user input. nativeEvents :: Capabilities -> Maybe Bool -- | How the session should handle unexpected alerts. unexpectedAlertBehavior :: Capabilities -> Maybe UnexpectedAlertBehavior -- | A list of (Text, Value) pairs specifying additional -- non-standard capabilities. additionalCaps :: Capabilities -> [Pair] -- | 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 -- capabilities are set to Nothing (no preference). defaultCaps :: Capabilities -- | Same as defaultCaps, but with all Maybe Bool -- capabilities set to Just True. allCaps :: 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. data Browser Firefox :: Maybe (PreparedProfile Firefox) -> LogLevel -> Maybe FilePath -> Browser -- | The firefox profile to use. If Nothing, a default temporary profile is -- automatically created and used. ffProfile :: Browser -> Maybe (PreparedProfile Firefox) -- | Firefox logging preference ffLogPref :: Browser -> LogLevel -- | Server-side path to Firefox binary. If Nothing, use a sensible -- system-based default. ffBinary :: Browser -> Maybe FilePath Chrome :: Maybe String -> Maybe FilePath -> [String] -> [ChromeExtension] -> Browser -- | Version of the Chrome Webdriver server server to use -- -- for more information on chromedriver see -- http://code.google.com/p/selenium/wiki/ChromeDriver chromeDriverVersion :: Browser -> Maybe String -- | Server-side path to Chrome binary. If Nothing, use a sensible -- system-based default. chromeBinary :: Browser -> Maybe FilePath -- | A list of command-line options to pass to the Chrome binary. chromeOptions :: Browser -> [String] -- | A list of extensions to use. chromeExtensions :: Browser -> [ChromeExtension] IE :: Bool -> Bool -> Maybe Text -> IEElementScrollBehavior -> Bool -> Bool -> Bool -> Integer -> Maybe FilePath -> IELogLevel -> Maybe Text -> Maybe Text -> Bool -> Bool -> Maybe Text -> Browser -- | Whether to skip the protected mode check. If set, tests may become -- flaky, unresponsive, or browsers may hang. If not set, and protected -- mode settings are not the same for all zones, an exception will be -- thrown on driver construction. ieIgnoreProtectedModeSettings :: Browser -> Bool -- | Indicates whether to skip the check that the browser's zoom level is -- set to 100%. Value is set to false by default. ieIgnoreZoomSetting :: Browser -> Bool -- | Allows the user to specify the initial URL loaded when IE starts. -- Intended to be used with ignoreProtectedModeSettings to allow the user -- to initialize IE in the proper Protected Mode zone. Using this -- capability may cause browser instability or flaky and unresponsive -- code. Only "best effort" support is provided when using this -- capability. ieInitialBrowserUrl :: Browser -> Maybe Text -- | Allows the user to specify whether elements are scrolled into the -- viewport for interaction to align with the top or bottom of the -- viewport. The default value is to align with the top of the viewport. ieElementScrollBehavior :: Browser -> IEElementScrollBehavior -- | Determines whether persistent hovering is enabled (true by default). -- Persistent hovering is achieved by continuously firing mouse over -- events at the last location the mouse cursor has been moved to. ieEnablePersistentHover :: Browser -> Bool -- | Determines whether the driver should attempt to remove obsolete -- elements from the element cache on page navigation (true by default). -- This is to help manage the IE driver's memory footprint , removing -- references to invalid elements. ieEnableElementCacheCleanup :: Browser -> Bool -- | Determines whether to require that the IE window have focus before -- performing any user interaction operations (mouse or keyboard events). -- This capability is false by default, but delivers much more accurate -- native events interactions. ieRequireWindowFocus :: Browser -> Bool -- | The timeout, in milliseconds, that the driver will attempt to locate -- and attach to a newly opened instance of Internet Explorer . The -- default is zero, which indicates waiting indefinitely. ieBrowserAttachTimeout :: Browser -> Integer -- | The path to file where server should write log messages to. By default -- it writes to stdout. ieLogFile :: Browser -> Maybe FilePath -- | The log level used by the server. Defaults to IELogFatal ieLogLevel :: Browser -> IELogLevel -- | The address of the host adapter on which the server will listen for -- commands. ieHost :: Browser -> Maybe Text -- | The path to the directory used to extract supporting files used by the -- server. Defaults to the TEMP directory if not specified. ieExtractPath :: Browser -> Maybe Text -- | Suppresses diagnostic output when the server is started. ieSilent :: Browser -> Bool -- | Forces launching Internet Explorer using the CreateProcess API. If -- this option is not specified, IE is launched using the IELaunchURL, if -- it is available. For IE 8 and above, this option requires the -- TabProcGrowth registry value to be set to 0. ieForceCreateProcess :: Browser -> Bool -- | Specifies command-line switches with which to launch Internet -- Explorer. This is only valid when used with the forceCreateProcess. ieSwitches :: Browser -> Maybe Text Opera :: Maybe FilePath -> Maybe String -> Bool -> Bool -> Bool -> Maybe Int -> Maybe FilePath -> Maybe Word16 -> Maybe String -> Maybe String -> Maybe FilePath -> LogLevel -> Browser -- | Server-side path to the Opera binary operaBinary :: Browser -> Maybe FilePath -- | Which Opera product we're using, e.g. "desktop", "core" operaProduct :: Browser -> Maybe String -- | Whether the Opera instance should stay open after we close the -- session. If false, closing the session closes the browser. operaDetach :: Browser -> Bool -- | Whether to auto-start the Opera binary. If false, OperaDriver will -- wait for a connection from the browser. By default this is True. operaAutoStart :: Browser -> Bool -- | Whether to use Opera's alternative implicit wait implementation. It -- will use an in-browser heuristic to guess when a page has finished -- loading. This feature is experimental, and disabled by default. operaIdle :: Browser -> Bool -- | (*nix only) which X display to use. operaDisplay :: Browser -> Maybe Int -- | Path to the launcher binary to use. The launcher is a gateway between -- OperaDriver and the Opera browser. If Nothing, OperaDriver will use -- the launcher supplied with the package. operaLauncher :: Browser -> Maybe FilePath -- | The port we should use to connect to Opera. If Just 0 , use a random -- port. If Nothing, use the default Opera port. The default opera -- constructor uses Just 0, since Nothing is likely to cause "address -- already in use" errors. operaPort :: Browser -> Maybe Word16 -- | The host Opera should connect to. Unless you're starting Opera -- manually you won't need this. operaHost :: Browser -> Maybe String -- | Command-line arguments to pass to Opera. operaOptions :: Browser -> Maybe String -- | Where to send the log output. If Nothing, logging is disabled. operaLogFile :: Browser -> Maybe FilePath -- | Log level preference. Defaults to LogInfo operaLogPref :: Browser -> LogLevel HTMLUnit :: Browser IPhone :: Browser IPad :: Browser Android :: Browser -- | some other browser, specified by a string name Browser :: Text -> Browser -- | Default Firefox settings. All Maybe fields are set to Nothing. -- ffLogPref is set to LogInfo. firefox :: Browser -- | Default Chrome settings. All Maybe fields are set to Nothing, no -- options are specified, and no extensions are used. chrome :: Browser -- | Default IE settings. See the IE constructor for more details on -- individual defaults ie :: Browser -- | Default Opera settings. See the Opera constructor for more -- details on individual defaults. opera :: Browser htmlUnit :: Browser iPhone :: Browser iPad :: Browser android :: Browser -- | Represents platform options supported by WebDriver. The value Any -- represents no preference. data Platform Windows :: Platform XP :: Platform Vista :: Platform Mac :: Platform Linux :: Platform Unix :: Platform Any :: Platform -- | Available settings for the proxy Capabilities field data ProxyType NoProxy :: ProxyType UseSystemSettings :: ProxyType AutoDetect :: ProxyType -- | Use a proxy auto-config file specified by URL PAC :: String -> ProxyType autoConfigUrl :: ProxyType -> String -- | Manually specify proxy hosts as hostname:port strings. Note that -- behavior is undefined for empty strings. Manual :: String -> String -> String -> ProxyType ftpProxy :: ProxyType -> String sslProxy :: ProxyType -> String httpProxy :: ProxyType -> String data UnexpectedAlertBehavior AcceptAlert :: UnexpectedAlertBehavior DismissAlert :: UnexpectedAlertBehavior IgnoreAlert :: UnexpectedAlertBehavior -- | Indicates a log verbosity level. Used in Firefox and -- Opera configuration. data LogLevel LogOff :: LogLevel LogSevere :: LogLevel LogWarning :: LogLevel LogInfo :: LogLevel LogConfig :: LogLevel LogFine :: LogLevel LogFiner :: LogLevel LogFinest :: LogLevel LogAll :: LogLevel -- | Logging levels for Internet Explorer data IELogLevel IELogTrace :: IELogLevel IELogDebug :: IELogLevel IELogInfo :: IELogLevel IELogWarn :: IELogLevel IELogError :: IELogLevel IELogFatal :: IELogLevel -- | Specifies how elements scroll into the viewport. (see -- ieElementScrollBehavior) data IEElementScrollBehavior AlignTop :: IEElementScrollBehavior AlignBottom :: IEElementScrollBehavior instance Eq Platform instance Show Platform instance Ord Platform instance Bounded Platform instance Enum Platform instance Eq ProxyType instance Show ProxyType instance Bounded UnexpectedAlertBehavior instance Enum UnexpectedAlertBehavior instance Eq UnexpectedAlertBehavior instance Ord UnexpectedAlertBehavior instance Read UnexpectedAlertBehavior instance Show UnexpectedAlertBehavior instance Eq LogLevel instance Show LogLevel instance Read LogLevel instance Ord LogLevel instance Bounded LogLevel instance Enum LogLevel instance Eq IELogLevel instance Show IELogLevel instance Read IELogLevel instance Ord IELogLevel instance Bounded IELogLevel instance Enum IELogLevel instance Eq IEElementScrollBehavior instance Ord IEElementScrollBehavior instance Show IEElementScrollBehavior instance Read IEElementScrollBehavior instance Enum IEElementScrollBehavior instance Bounded IEElementScrollBehavior instance Eq Browser instance Show Browser instance Eq Capabilities instance Show Capabilities instance FromJSON IEElementScrollBehavior instance ToJSON IEElementScrollBehavior instance Default IEElementScrollBehavior instance FromJSON IELogLevel instance ToJSON IELogLevel instance Default IELogLevel instance FromJSON LogLevel instance ToJSON LogLevel instance Default LogLevel instance FromJSON UnexpectedAlertBehavior instance ToJSON UnexpectedAlertBehavior instance ToJSON ProxyType instance FromJSON ProxyType instance FromJSON Platform instance ToJSON Platform instance FromJSON Browser instance ToJSON Browser instance Default Browser instance FromJSON Capabilities instance ToJSON Capabilities instance Default Capabilities module Test.WebDriver.Session -- | A class for monads that carry a WebDriver session with them. The -- MonadBaseControl superclass is used for exception handling through the -- lifted-base package. class MonadBaseControl IO s => WDSessionState s getSession :: WDSessionState s => s WDSession putSession :: WDSessionState s => WDSession -> s () modifySession :: WDSessionState s => (WDSession -> WDSession) -> s () -- | The local state of a WebDriver session. This structure is passed -- implicitly through all WD computations data WDSession WDSession :: ByteString -> Int -> ByteString -> Maybe SessionId -> [(Request, Response ByteString)] -> ((Request, Response ByteString) -> [(Request, Response ByteString)] -> [(Request, Response ByteString)]) -> Manager -> WDSession wdSessHost :: WDSession -> ByteString wdSessPort :: WDSession -> Int wdSessBasePath :: WDSession -> ByteString -- | 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 wdSessId :: WDSession -> Maybe SessionId -- | The complete history of HTTP requests and responses, most recent -- first. wdSessHist :: WDSession -> [(Request, Response ByteString)] -- | Update function used to append new entries to session history wdSessHistUpdate :: WDSession -> (Request, Response ByteString) -> [(Request, Response ByteString)] -> [(Request, Response ByteString)] -- | HTTP Manager used for connection pooling by the http-client -- library. wdSessHTTPManager :: WDSession -> Manager -- | The last HTTP request issued by this session, if any. lastHTTPRequest :: WDSession -> Maybe Request -- | 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. newtype SessionId SessionId :: Text -> SessionId instance Eq SessionId instance Ord SessionId instance Show SessionId instance Read SessionId instance FromJSON SessionId instance ToJSON SessionId instance (Monoid w, WDSessionState wd) => WDSessionState (RWST r w s wd) instance (Monoid w, WDSessionState m) => WDSessionState (RWST r w s m) instance (Error e, WDSessionState m) => WDSessionState (ErrorT e m) instance WDSessionState m => WDSessionState (ReaderT r m) instance (Monoid w, WDSessionState m) => WDSessionState (WriterT w m) instance WDSessionState m => WDSessionState (IdentityT m) instance WDSessionState m => WDSessionState (MaybeT m) instance WDSessionState m => WDSessionState (StateT s m) instance WDSessionState m => WDSessionState (StateT s m) module Test.WebDriver.Config -- | WebDriver session configuration data WDConfig WDConfig :: String -> Int -> RequestHeaders -> Capabilities -> Bool -> String -> Maybe Manager -> WDConfig -- | Host name of the WebDriver server for this session (default 127.0.0.1) wdHost :: WDConfig -> String -- | Port number of the server (default 4444) wdPort :: WDConfig -> Int -- | Additional request headers to send to the server during session -- creation (default []) wdRequestHeaders :: WDConfig -> RequestHeaders -- | Capabilities to use for this session wdCapabilities :: WDConfig -> Capabilities -- | Whether or not we should keep a history of HTTP requests/responses -- -- By default, only the last request/response pair is stored (O(1) heap -- consumption). Enable this option for more detailed debugging info for -- HTTP requests. wdKeepSessHist :: WDConfig -> Bool -- | Base path for all API requests (default "wdhub") wdBasePath :: WDConfig -> String -- | Use the given http-client Manager instead of the default wdHTTPManager :: WDConfig -> Maybe Manager -- | 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. defaultConfig :: WDConfig -- | Constructs a new WDSession from a given WDConfig mkSession :: MonadBase IO m => WDConfig -> m WDSession instance Default WDConfig module Test.WebDriver.Class -- | A class for monads that can handle wire protocol requests. This is the -- operation underlying all of the high-level commands exported in -- Test.WebDriver.Commands. For more information on the wire -- protocol see -- http://code.google.com/p/selenium/wiki/JsonWireProtocol class WDSessionState wd => WebDriver wd doCommand :: (WebDriver wd, ToJSON a, FromJSON b) => RequestHeaders -> Method -> Text -> a -> wd b -- | HTTP method (flat string type). type Method = ByteString -- | HTTP Method constants. methodDelete :: Method -- | HTTP Method constants. methodGet :: Method -- | HTTP Method constants. methodPost :: Method instance (Monoid w, WebDriver wd) => WebDriver (RWST r w s wd) instance (Monoid w, WebDriver wd) => WebDriver (RWST r w s wd) instance (Error e, WebDriver wd) => WebDriver (ErrorT e wd) instance WebDriver wd => WebDriver (ReaderT r wd) instance (Monoid w, WebDriver wd) => WebDriver (WriterT w wd) instance WebDriver wd => WebDriver (IdentityT wd) instance WebDriver wd => WebDriver (MaybeT wd) instance WebDriver wd => WebDriver (StateT s wd) instance WebDriver wd => WebDriver (StateT s wd) -- | Internal functions used to implement the functions exported by -- Test.WebDriver.Commands. These may be useful for implementing -- non-standard webdriver commands. module Test.WebDriver.Commands.Internal doCommand :: (WebDriver wd, ToJSON a, FromJSON b) => RequestHeaders -> Method -> Text -> a -> wd b -- | This a convenient wrapper around doCommand that automatically -- prepends the session URL parameter to the wire command URL. For -- example, passing a URL of "refresh" will expand to -- "session:sessionIdrefresh", where :sessionId is a URL -- parameter as described in -- http://code.google.com/p/selenium/wiki/JsonWireProtocol doSessCommand :: (WebDriver wd, ToJSON a, FromJSON b) => Method -> Text -> a -> wd b -- | 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. newtype SessionId SessionId :: Text -> SessionId -- | A wrapper around doSessCommand to create element URLs. For -- example, passing a URL of "/active" will expand to -- "session:sessionIdelement:id/active", where :sessionId -- and :id are URL parameters as described in the wire protocol. doElemCommand :: (WebDriver wd, ToJSON a, FromJSON b) => Method -> Element -> Text -> a -> wd b -- | An opaque identifier for a web page element. newtype Element Element :: Text -> Element -- | A wrapper around doSessCommand to create window handle URLS. -- For example, passing a URL of "/size" will expand to -- "session:sessionIdwindow:windowHandle/", where -- :sessionId and :windowHandle are URL parameters as described in the -- wire protocol doWinCommand :: (WebDriver wd, ToJSON a, FromJSON b) => Method -> WindowHandle -> Text -> a -> wd b -- | An opaque identifier for a browser window newtype WindowHandle WindowHandle :: Text -> WindowHandle -- | A special WindowHandle that always refers to the currently -- focused window. This is also used by the Default instance. currentWindow :: WindowHandle -- | A command requiring a session ID was attempted when no session ID was -- available. newtype NoSessionId NoSessionId :: String -> NoSessionId instance Typeable NoSessionId instance Eq Element instance Ord Element instance Show Element instance Read Element instance Eq WindowHandle instance Ord WindowHandle instance Show WindowHandle instance Read WindowHandle instance FromJSON WindowHandle instance ToJSON WindowHandle instance Eq NoSessionId instance Show NoSessionId instance Exception NoSessionId instance Default WindowHandle instance ToJSON Element instance FromJSON Element module Test.WebDriver.Exceptions -- | An invalid URL was given newtype InvalidURL InvalidURL :: String -> InvalidURL -- | A command requiring a session ID was attempted when no session ID was -- available. newtype NoSessionId NoSessionId :: String -> NoSessionId -- | An error occured when parsing a JSON value. newtype BadJSON BadJSON :: String -> BadJSON -- | An unexpected HTTP status was sent by the server. data HTTPStatusUnknown HTTPStatusUnknown :: Int -> String -> HTTPStatusUnknown -- | HTTP connection errors. data HTTPConnError HTTPConnError :: String -> Int -> HTTPConnError -- | A command was sent to the WebDriver server that it didn't recognize. newtype UnknownCommand UnknownCommand :: String -> UnknownCommand -- | A server-side exception occured newtype ServerError ServerError :: String -> ServerError -- | This exception encapsulates a broad variety of exceptions that can -- occur when a command fails. data FailedCommand FailedCommand :: FailedCommandType -> FailedCommandInfo -> FailedCommand -- | The type of failed command exception that occured. data FailedCommandType NoSuchElement :: FailedCommandType NoSuchFrame :: FailedCommandType UnknownFrame :: FailedCommandType StaleElementReference :: FailedCommandType ElementNotVisible :: FailedCommandType InvalidElementState :: FailedCommandType UnknownError :: FailedCommandType ElementIsNotSelectable :: FailedCommandType JavascriptError :: FailedCommandType XPathLookupError :: FailedCommandType Timeout :: FailedCommandType NoSuchWindow :: FailedCommandType InvalidCookieDomain :: FailedCommandType UnableToSetCookie :: FailedCommandType UnexpectedAlertOpen :: FailedCommandType NoAlertOpen :: FailedCommandType ScriptTimeout :: FailedCommandType InvalidElementCoordinates :: FailedCommandType IMENotAvailable :: FailedCommandType IMEEngineActivationFailed :: FailedCommandType InvalidSelector :: FailedCommandType SessionNotCreated :: FailedCommandType MoveTargetOutOfBounds :: FailedCommandType InvalidXPathSelector :: FailedCommandType InvalidXPathSelectorReturnType :: FailedCommandType -- | Detailed information about the failed command provided by the server. data FailedCommandInfo FailedCommandInfo :: String -> Maybe WDSession -> Maybe ByteString -> Maybe String -> [StackFrame] -> FailedCommandInfo -- | The error message. errMsg :: FailedCommandInfo -> String -- | The session associated with the exception. errSess :: FailedCommandInfo -> Maybe WDSession -- | A screen shot of the focused window when the exception occured, if -- provided. errScreen :: FailedCommandInfo -> Maybe ByteString -- | The "class" in which the exception was raised, if provided. errClass :: FailedCommandInfo -> Maybe String -- | A stack trace of the exception. errStack :: FailedCommandInfo -> [StackFrame] -- | An individual stack frame from the stack trace provided by the server -- during a FailedCommand. data StackFrame StackFrame :: String -> String -> String -> Word -> StackFrame sfFileName :: StackFrame -> String sfClassName :: StackFrame -> String sfMethodName :: StackFrame -> String sfLineNumber :: StackFrame -> Word -- | Constructs a FailedCommandInfo from only an error message. mkFailedCommandInfo :: WDSessionState s => String -> s FailedCommandInfo -- | Convenience function to throw a FailedCommand locally with no -- server-side info present. failedCommand :: WDSessionState s => FailedCommandType -> String -> s a module Test.WebDriver.Commands.Wait -- | Wait until either the given action succeeds or the timeout is reached. -- The action will be retried every .5 seconds until no -- ExpectFailed or FailedCommand NoSuchElement -- exceptions occur. If the timeout is reached, then a Timeout -- exception will be raised. The timeout value is expressed in seconds. waitUntil :: WDSessionState m => Double -> m a -> m a -- | Similar to waitUntil but allows you to also specify the poll -- frequency of the WD action. The frequency is expressed as an -- integer in microseconds. waitUntil' :: WDSessionState m => Int -> Double -> m a -> m a -- | Like waitUntil, but retries the action until it fails or until -- the timeout is exceeded. waitWhile :: WDSessionState m => Double -> m a -> m () -- | Like waitUntil', but retries the action until it either fails -- or until the timeout is exceeded. waitWhile' :: WDSessionState m => Int -> Double -> m a -> m () -- | An exception representing the failure of an expected condition. data ExpectFailed -- | An expected condition. This function allows you to express assertions -- in your explicit wait. This function raises ExpectFailed if the -- given boolean is False, and otherwise does nothing. expect :: MonadBaseControl IO m => Bool -> m () -- | throws ExpectFailed. This is nice for writing your own -- abstractions. unexpected :: MonadBaseControl IO m => String -> m a -- | Convenience function to catch FailedCommand Timeout -- exceptions and perform some action. -- -- Example: -- --
--   waitUntil 5 (getText <=< findElem $ ByCSS ".class")
--      `onTimeout` return ""
--   
onTimeout :: MonadBaseControl IO m => m a -> m a -> m a -- | Apply a monadic predicate to every element in a list, and -- expect that at least one succeeds. expectAny :: MonadBaseControl IO m => (a -> m Bool) -> [a] -> m () -- | Apply a monadic predicate to every element in a list, and -- expect that all succeed. expectAll :: MonadBaseControl IO m => (a -> m Bool) -> [a] -> m () -- | if' lifted to Monad. Unlike liftM3 if', -- this is short-circuiting in the monad, such that only the predicate -- action and one of the remaining argument actions are executed. ifM :: (ToBool bool, Monad m) => m bool -> m a -> m a -> m a -- | Lifted inclusive disjunction. Unlike liftM2 (||), This -- function is short-circuiting in the monad. Fixity is the same as -- || (infixr 2). (<||>) :: (ToBool bool, Boolean bool, Monad m) => m bool -> m bool -> m bool -- | Lifted conjunction. Unlike liftM2 (&&), this -- function is short-circuiting in the monad. Fixity is the same as -- && (infxr 3). (<&&>) :: (ToBool bool, Boolean bool, Monad m) => m bool -> m bool -> m bool -- | Lifted boolean negation. notM :: (Boolean bool, Monad m) => m bool -> m bool instance Typeable ExpectFailed instance Show ExpectFailed instance Eq ExpectFailed instance Exception ExpectFailed -- | This module exports basic WD actions that can be used to interact with -- a browser session. module Test.WebDriver.Commands -- | Create a new session with the given Capabilities. createSession :: WebDriver wd => RequestHeaders -> Capabilities -> wd WDSession -- | Close the current session and the browser associated with it. closeSession :: WebDriver wd => wd () -- | Retrieve a list of active sessions and their Capabilities. sessions :: WebDriver wd => RequestHeaders -> wd [(SessionId, Capabilities)] -- | Get the actual Capabilities of the current session. getCaps :: WebDriver wd => wd Capabilities -- | Opens a new page by the given URL. openPage :: WebDriver wd => String -> wd () -- | Navigate forward in the browser history. forward :: WebDriver wd => wd () -- | Navigate backward in the browser history. back :: WebDriver wd => wd () -- | Refresh the current page refresh :: WebDriver wd => wd () -- | Gets the URL of the current page. getCurrentURL :: WebDriver wd => wd String -- | Get the current page source getSource :: WebDriver wd => wd Text -- | Get the title of the current page. getTitle :: WebDriver wd => wd Text -- | Grab a screenshot of the current page as a PNG image screenshot :: WebDriver wd => wd ByteString -- | Grab a screenshot as a base-64 encoded PNG image. This is the -- protocol-defined format. screenshotBase64 :: WebDriver wd => wd ByteString -- | Sets the amount of time (ms) we implicitly wait when searching for -- elements. setImplicitWait :: WebDriver wd => Integer -> wd () -- | Sets the amount of time (ms) we wait for an asynchronous script to -- return a result. setScriptTimeout :: WebDriver wd => Integer -> wd () -- | Sets the amount of time (ms) to wait for a page to finish loading -- before throwing a Timeout exception. setPageLoadTimeout :: WebDriver wd => Integer -> wd () -- | An opaque identifier for a web page element. newtype Element Element :: Text -> Element -- | Specifies element(s) within a DOM tree using various selection -- methods. data Selector ById :: Text -> Selector ByName :: Text -> Selector -- | (Note: multiple classes are not allowed. For more control, use -- ByCSS) ByClass :: Text -> Selector ByTag :: Text -> Selector ByLinkText :: Text -> Selector ByPartialLinkText :: Text -> Selector ByCSS :: Text -> Selector ByXPath :: Text -> Selector -- | Find an element on the page using the given element selector. findElem :: WebDriver wd => Selector -> wd Element -- | Find all elements on the page matching the given selector. findElems :: WebDriver wd => Selector -> wd [Element] -- | Search for an element using the given element as root. findElemFrom :: WebDriver wd => Element -> Selector -> wd Element -- | Find all elements matching a selector, using the given element as -- root. findElemsFrom :: WebDriver wd => Element -> Selector -> wd [Element] -- | Click on an element. click :: WebDriver wd => Element -> wd () -- | Submit a form element. This may be applied to descendents of a form -- element as well. submit :: WebDriver wd => Element -> wd () -- | Get all visible text within this element. getText :: WebDriver wd => Element -> wd Text -- | Send a sequence of keystrokes to an element. All modifier keys are -- released at the end of the function. For more information about -- modifier keys, see -- http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/value sendKeys :: WebDriver wd => Text -> Element -> wd () -- | Similar to sendKeys, but doesn't implicitly release modifier keys -- afterwards. This allows you to combine modifiers with mouse clicks. sendRawKeys :: WebDriver wd => Text -> Element -> wd () -- | Clear a textarea or text input element's value. clearInput :: WebDriver wd => Element -> wd () -- | Retrieve the value of an element's attribute attr :: WebDriver wd => Element -> Text -> wd (Maybe Text) -- | Retrieve the value of an element's computed CSS property cssProp :: WebDriver wd => Element -> Text -> wd (Maybe Text) -- | Retrieve an element's current position. elemPos :: WebDriver wd => Element -> wd (Int, Int) -- | Retrieve an element's current size. elemSize :: WebDriver wd => Element -> wd (Word, Word) -- | Determine if the element is selected. isSelected :: WebDriver wd => Element -> wd Bool -- | Determine if the element is enabled. isEnabled :: WebDriver wd => Element -> wd Bool -- | Determine if the element is displayed. isDisplayed :: WebDriver wd => Element -> wd Bool -- | Return the tag name of the given element. tagName :: WebDriver wd => Element -> wd Text -- | Return the element that currently has focus. activeElem :: WebDriver wd => wd Element -- | Describe the element. Returns a JSON object whose meaning is currently -- undefined by the WebDriver protocol. elemInfo :: WebDriver wd => Element -> wd Value -- | Determines if two element identifiers refer to the same element. (<==>) :: WebDriver wd => Element -> Element -> wd Bool -- | Determines if two element identifiers refer to different elements. () :: WebDriver wd => Element -> Element -> wd Bool -- | Inject a snippet of Javascript into the page for execution in the -- context of the currently selected frame. The executed script is -- assumed to be synchronous and the result of evaluating the script is -- returned and converted to an instance of FromJSON. -- -- The first parameter defines arguments to pass to the javascript -- function. Arguments of type Element will be converted to the -- corresponding DOM element. Likewise, any elements in the script result -- will be returned to the client as Elements. -- -- The second parameter defines the script itself in the form of a -- function body. The value returned by that function will be returned to -- the client. The function will be invoked with the provided argument -- list and the values may be accessed via the arguments object in the -- order specified. executeJS :: (WebDriver wd, FromJSON a) => [JSArg] -> Text -> wd a -- | Executes a snippet of Javascript code asynchronously. This function -- works similarly to executeJS, except that the Javascript is -- passed a callback function as its final argument. The script should -- call this function to signal that it has finished executing, passing -- to it a value that will be returned as the result of asyncJS. A result -- of Nothing indicates that the Javascript function timed out (see -- setScriptTimeout) asyncJS :: (WebDriver wd, FromJSON a) => [JSArg] -> Text -> wd (Maybe a) -- | An existential wrapper for any ToJSON instance. This allows us -- to pass parameters of many different types to Javascript code. data JSArg JSArg :: a -> JSArg -- | An opaque identifier for a browser window newtype WindowHandle WindowHandle :: Text -> WindowHandle -- | A special WindowHandle that always refers to the currently -- focused window. This is also used by the Default instance. currentWindow :: WindowHandle -- | Returns a handle to the currently focused window getCurrentWindow :: WebDriver wd => wd WindowHandle -- | Closes the given window closeWindow :: WebDriver wd => WindowHandle -> wd () -- | Returns a list of all windows available to the session windows :: WebDriver wd => wd [WindowHandle] focusWindow :: WebDriver wd => WindowHandle -> wd () -- | Maximizes the current window if not already maximized maximize :: WebDriver wd => wd () -- | Get the dimensions of the current window. getWindowSize :: WebDriver wd => wd (Word, Word) -- | Set the dimensions of the current window. setWindowSize :: WebDriver wd => (Word, Word) -> wd () -- | Get the coordinates of the current window. getWindowPos :: WebDriver wd => wd (Int, Int) -- | Set the coordinates of the current window. setWindowPos :: WebDriver wd => (Int, Int) -> wd () -- | Switch focus to the frame specified by the FrameSelector. focusFrame :: WebDriver wd => FrameSelector -> wd () -- | Specifies the frame used by focusFrame data FrameSelector WithIndex :: Integer -> FrameSelector -- | focus on a frame by name or ID WithName :: Text -> FrameSelector -- | focus on a frame Element WithElement :: Element -> FrameSelector -- | focus on the first frame, or the main document if iframes are used. DefaultFrame :: FrameSelector -- | 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. data Cookie Cookie :: Text -> Text -> Maybe Text -> Maybe Text -> Maybe Bool -> Maybe Integer -> Cookie cookName :: Cookie -> Text cookValue :: Cookie -> Text -- | path of this cookie. if Nothing, defaults to / cookPath :: Cookie -> Maybe Text -- | domain of this cookie. if Nothing, the current pages domain is used cookDomain :: Cookie -> Maybe Text -- | Is this cookie secure? cookSecure :: Cookie -> Maybe Bool -- | Expiry date expressed as seconds since the Unix epoch Nothing -- indicates that the cookie never expires cookExpiry :: Cookie -> Maybe Integer -- | 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. mkCookie :: Text -> Text -> Cookie -- | Retrieve all cookies visible to the current page. cookies :: WebDriver wd => wd [Cookie] -- | Set a cookie. If the cookie path is not specified, it will default to -- "/". Likewise, if the domain is omitted, it will default to the -- current page's domain setCookie :: WebDriver wd => Cookie -> wd () -- | Delete a cookie. This will do nothing is the cookie isn't visible to -- the current page. deleteCookie :: WebDriver wd => Cookie -> wd () -- | Delete all visible cookies on the current page. deleteVisibleCookies :: WebDriver wd => wd () deleteCookieByName :: WebDriver wd => Text -> wd () -- | Get the text of an alert dialog. getAlertText :: WebDriver wd => wd Text -- | Sends keystrokes to Javascript prompt() dialog. replyToAlert :: WebDriver wd => Text -> wd () -- | Accepts the currently displayed alert dialog. acceptAlert :: WebDriver wd => wd () -- | Dismisses the currently displayed alert dialog. dismissAlert :: WebDriver wd => wd () -- | Moves the mouse to the given position relative to the active element. moveTo :: WebDriver wd => (Int, Int) -> wd () -- | Moves the mouse to the center of a given element. moveToCenter :: WebDriver wd => Element -> wd () -- | Moves the mouse to the given position relative to the given element. moveToFrom :: WebDriver wd => (Int, Int) -> Element -> wd () -- | Click at the current mouse position with the given mouse button. clickWith :: WebDriver wd => MouseButton -> wd () -- | A mouse button data MouseButton LeftButton :: MouseButton MiddleButton :: MouseButton RightButton :: MouseButton -- | Press and hold the left mouse button down. Note that undefined -- behavior occurs if the next mouse command is not mouseUp. mouseDown :: WebDriver wd => wd () -- | Release the left mouse button. mouseUp :: WebDriver wd => wd () -- | Perform the given action with the left mouse button held down. The -- mouse is automatically released afterwards. withMouseDown :: WebDriver wd => wd a -> wd a -- | Double click at the current mouse location. doubleClick :: WebDriver wd => wd () -- | An HTML 5 storage type data WebStorageType LocalStorage :: WebStorageType SessionStorage :: WebStorageType -- | Get the current number of keys in a web storage area. storageSize :: WebDriver wd => WebStorageType -> wd Integer -- | Get a list of all keys from a web storage area. getAllKeys :: WebDriver wd => WebStorageType -> wd [Text] -- | Delete all keys within a given web storage area. deleteAllKeys :: WebDriver wd => WebStorageType -> wd () -- | Get the value associated with a key in the given web storage area. -- Unset keys result in empty strings, since the Web Storage spec makes -- no distinction between the empty string and an undefined value. getKey :: WebDriver wd => WebStorageType -> Text -> wd Text -- | Set a key in the given web storage area. setKey :: WebDriver wd => WebStorageType -> Text -> Text -> wd Text -- | Delete a key in the given web storage area. deleteKey :: WebDriver wd => WebStorageType -> Text -> wd () data ApplicationCacheStatus Uncached :: ApplicationCacheStatus Idle :: ApplicationCacheStatus Checking :: ApplicationCacheStatus Downloading :: ApplicationCacheStatus UpdateReady :: ApplicationCacheStatus Obsolete :: ApplicationCacheStatus getApplicationCacheStatus :: WebDriver wd => wd ApplicationCacheStatus -- | A screen orientation data Orientation Landscape :: Orientation Portrait :: Orientation -- | Get the current screen orientation for rotatable display devices. getOrientation :: WebDriver wd => wd Orientation -- | Set the current screen orientation for rotatable display devices. setOrientation :: WebDriver wd => Orientation -> wd () -- | Get the current geographical location of the device. getLocation :: WebDriver wd => wd (Int, Int, Int) -- | Set the current geographical location of the device. setLocation :: WebDriver wd => (Int, Int, Int) -> wd () -- | Single tap on the touch screen at the given element's location. touchClick :: WebDriver wd => Element -> wd () -- | Emulates pressing a finger down on the screen at the given location. touchDown :: WebDriver wd => (Int, Int) -> wd () -- | Emulates removing a finger from the screen at the given location. touchUp :: WebDriver wd => (Int, Int) -> wd () -- | Emulates moving a finger on the screen to the given location. touchMove :: WebDriver wd => (Int, Int) -> wd () -- | Emulate finger-based touch scroll. Use this function if you don't care -- where the scroll begins touchScroll :: WebDriver wd => (Int, Int) -> wd () -- | Emulate finger-based touch scroll, starting from the given location -- relative to the given element. touchScrollFrom :: WebDriver wd => (Int, Int) -> Element -> wd () -- | Emulate a double click on a touch device. touchDoubleClick :: WebDriver wd => Element -> wd () -- | Emulate a long click on a touch device. touchLongClick :: WebDriver wd => Element -> wd () -- | Emulate a flick on the touch screen. The coordinates indicate x and y -- velocity, respectively. Use this function if you don't care where the -- flick starts. touchFlick :: WebDriver wd => (Int, Int) -> wd () -- | Emulate a flick on the touch screen. touchFlickFrom :: WebDriver wd => Int -> (Int, Int) -> Element -> wd () availableIMEEngines :: WebDriver wd => wd [Text] activeIMEEngine :: WebDriver wd => wd Text checkIMEActive :: WebDriver wd => wd Bool activateIME :: WebDriver wd => Text -> wd () deactivateIME :: WebDriver wd => wd () -- | Uploads a file from the local filesystem by its file path. uploadFile :: WebDriver wd => FilePath -> wd () -- | Uploads a raw bytestring with associated file info. uploadRawFile :: WebDriver wd => FilePath -> Integer -> ByteString -> wd () -- | Lowest level interface to the file uploading mechanism. This allows -- you to specify the exact details of the zip entry sent across network. uploadZipEntry :: WebDriver wd => Entry -> wd () -- | Get information from the server as a JSON Object. For more -- information about this object see -- http://code.google.com/p/selenium/wiki/JsonWireProtocol#/status serverStatus :: WebDriver wd => RequestHeaders -> wd Value -- | Retrieve the log buffer for a given log type. The server-side log -- buffer is reset after each request. -- -- Which log types are available is server defined, but the wire protocol -- lists these as common log types: client, driver, browser, server getLogs :: WebDriver wd => LogType -> wd [LogEntry] -- | Get a list of available log types. getLogTypes :: WebDriver wd => wd [LogType] type LogType = String -- | A record that represents a single log entry. data LogEntry LogEntry :: Integer -> LogLevel -> Text -> LogEntry -- | timestamp for the log entry. The standard does not specify the epoch -- or the unit of time. logTime :: LogEntry -> Integer -- | log verbosity level logLevel :: LogEntry -> LogLevel logMsg :: LogEntry -> Text -- | Indicates a log verbosity level. Used in Firefox and -- Opera configuration. data LogLevel LogOff :: LogLevel LogSevere :: LogLevel LogWarning :: LogLevel LogInfo :: LogLevel LogConfig :: LogLevel LogFine :: LogLevel LogFiner :: LogLevel LogFinest :: LogLevel LogAll :: LogLevel instance ToJSON Cookie instance Eq FrameSelector instance Show FrameSelector instance Read FrameSelector instance Eq Cookie instance Show Cookie instance Eq Selector instance Show Selector instance Ord Selector instance Eq Orientation instance Show Orientation instance Ord Orientation instance Bounded Orientation instance Enum Orientation instance Eq MouseButton instance Show MouseButton instance Ord MouseButton instance Bounded MouseButton instance Enum MouseButton instance Eq WebStorageType instance Show WebStorageType instance Ord WebStorageType instance Bounded WebStorageType instance Enum WebStorageType instance Eq LogEntry instance Ord LogEntry instance Show LogEntry instance Read LogEntry instance Eq ApplicationCacheStatus instance Enum ApplicationCacheStatus instance Bounded ApplicationCacheStatus instance Ord ApplicationCacheStatus instance Show ApplicationCacheStatus instance Read ApplicationCacheStatus instance FromJSON ApplicationCacheStatus instance FromJSON LogEntry instance FromJSON MouseButton instance ToJSON MouseButton instance FromJSON Orientation instance ToJSON Orientation instance ToJSON Selector instance FromJSON Cookie instance ToJSON FrameSelector instance ToJSON JSArg module Test.WebDriver.Monad -- | A monadic interface to the WebDriver server. This monad is simply a -- state monad transformer over IO, threading session information -- between sequential webdriver commands newtype WD a WD :: (StateT WDSession IO a) -> WD a -- | Executes a WD computation within the IO monad, using the -- given WDSession. runWD :: WDSession -> WD a -> IO a -- | 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 runSession :: WDConfig -> WD a -> IO a -- | 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. withSession :: WDSession -> WD a -> WD a -- | A finalizer ensuring that the session is always closed at the end of -- the given WD action, regardless of any exceptions. finallyClose :: WebDriver wd => wd a -> wd a -- | Exception handler that closes the session when an asynchronous -- exception is thrown, but otherwise leaves the session open if the -- action was successful. closeOnException :: WebDriver wd => wd a -> wd a -- | Prints a history of API requests to stdout after computing the given -- action. dumpSessionHistory :: (MonadIO wd, WebDriver wd) => wd a -> wd a instance Functor WD instance Applicative WD instance Monad WD instance MonadIO WD instance MonadThrow WD instance MonadCatch WD instance WebDriver WD instance WDSessionState WD instance MonadBaseControl IO WD instance MonadBase IO WD module Test.WebDriver.Types -- | A monadic interface to the WebDriver server. This monad is simply a -- state monad transformer over IO, threading session information -- between sequential webdriver commands newtype WD a WD :: (StateT WDSession IO a) -> WD a -- | The local state of a WebDriver session. This structure is passed -- implicitly through all WD computations data WDSession WDSession :: ByteString -> Int -> ByteString -> Maybe SessionId -> [(Request, Response ByteString)] -> ((Request, Response ByteString) -> [(Request, Response ByteString)] -> [(Request, Response ByteString)]) -> Manager -> WDSession wdSessHost :: WDSession -> ByteString wdSessPort :: WDSession -> Int wdSessBasePath :: WDSession -> ByteString -- | 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 wdSessId :: WDSession -> Maybe SessionId -- | The complete history of HTTP requests and responses, most recent -- first. wdSessHist :: WDSession -> [(Request, Response ByteString)] -- | Update function used to append new entries to session history wdSessHistUpdate :: WDSession -> (Request, Response ByteString) -> [(Request, Response ByteString)] -> [(Request, Response ByteString)] -- | HTTP Manager used for connection pooling by the http-client -- library. wdSessHTTPManager :: WDSession -> Manager -- | 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. newtype SessionId SessionId :: Text -> SessionId -- | WebDriver session configuration data WDConfig WDConfig :: String -> Int -> RequestHeaders -> Capabilities -> Bool -> String -> Maybe Manager -> WDConfig -- | Host name of the WebDriver server for this session (default 127.0.0.1) wdHost :: WDConfig -> String -- | Port number of the server (default 4444) wdPort :: WDConfig -> Int -- | Additional request headers to send to the server during session -- creation (default []) wdRequestHeaders :: WDConfig -> RequestHeaders -- | Capabilities to use for this session wdCapabilities :: WDConfig -> Capabilities -- | Whether or not we should keep a history of HTTP requests/responses -- -- By default, only the last request/response pair is stored (O(1) heap -- consumption). Enable this option for more detailed debugging info for -- HTTP requests. wdKeepSessHist :: WDConfig -> Bool -- | Base path for all API requests (default "wdhub") wdBasePath :: WDConfig -> String -- | Use the given http-client Manager instead of the default wdHTTPManager :: WDConfig -> Maybe Manager -- | 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. defaultConfig :: WDConfig -- | A structure describing the capabilities of a session. This record -- serves dual roles. -- -- data Capabilities Capabilities :: Browser -> Maybe String -> Platform -> ProxyType -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe UnexpectedAlertBehavior -> [Pair] -> Capabilities -- | Browser choice and browser specific settings. browser :: Capabilities -> Browser -- | Browser version to use. version :: Capabilities -> Maybe String -- | Platform on which the browser should run. platform :: Capabilities -> Platform -- | Proxy configuration settings. proxy :: Capabilities -> ProxyType -- | Whether the session supports executing JavaScript via -- executeJS and asyncJS. javascriptEnabled :: Capabilities -> Maybe Bool -- | Whether the session supports taking screenshots of the current page -- with the screenshot command takesScreenshot :: Capabilities -> Maybe Bool -- | Whether the session can interact with modal popups, such as -- window.alert and window.confirm via acceptAlerts, -- dismissAlerts, etc. handlesAlerts :: Capabilities -> Maybe Bool -- | Whether the session can interact with database storage. databaseEnabled :: Capabilities -> Maybe Bool -- | Whether the session can set and query the browser's location context -- with setLocation and getLocation. locationContextEnabled :: Capabilities -> Maybe Bool -- | Whether the session can interact with the application cache . applicationCacheEnabled :: Capabilities -> Maybe Bool -- | Whether the session can query for the browser's connectivity and -- disable it if desired browserConnectionEnabled :: Capabilities -> Maybe Bool -- | Whether the session supports CSS selectors when searching for -- elements. cssSelectorsEnabled :: Capabilities -> Maybe Bool -- | Whether Web Storage (getKey, setKey, etc) support is -- enabled webStorageEnabled :: Capabilities -> Maybe Bool -- | Whether the session can rotate the current page's current layout -- between Portrait and Landscape orientations. rotatable :: Capabilities -> Maybe Bool -- | Whether the session should accept all SSL certs by default acceptSSLCerts :: Capabilities -> Maybe Bool -- | Whether the session is capable of generating native OS events when -- simulating user input. nativeEvents :: Capabilities -> Maybe Bool -- | How the session should handle unexpected alerts. unexpectedAlertBehavior :: Capabilities -> Maybe UnexpectedAlertBehavior -- | A list of (Text, Value) pairs specifying additional -- non-standard capabilities. additionalCaps :: Capabilities -> [Pair] -- | 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 -- capabilities are set to Nothing (no preference). defaultCaps :: Capabilities -- | Same as defaultCaps, but with all Maybe Bool -- capabilities set to Just True. allCaps :: Capabilities -- | Represents platform options supported by WebDriver. The value Any -- represents no preference. data Platform Windows :: Platform XP :: Platform Vista :: Platform Mac :: Platform Linux :: Platform Unix :: Platform Any :: Platform -- | Available settings for the proxy Capabilities field data ProxyType NoProxy :: ProxyType UseSystemSettings :: ProxyType AutoDetect :: ProxyType -- | Use a proxy auto-config file specified by URL PAC :: String -> ProxyType autoConfigUrl :: ProxyType -> String -- | Manually specify proxy hosts as hostname:port strings. Note that -- behavior is undefined for empty strings. Manual :: String -> String -> String -> ProxyType ftpProxy :: ProxyType -> String sslProxy :: ProxyType -> String httpProxy :: ProxyType -> String data UnexpectedAlertBehavior AcceptAlert :: UnexpectedAlertBehavior DismissAlert :: UnexpectedAlertBehavior IgnoreAlert :: UnexpectedAlertBehavior -- | 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. data Browser Firefox :: Maybe (PreparedProfile Firefox) -> LogLevel -> Maybe FilePath -> Browser -- | The firefox profile to use. If Nothing, a default temporary profile is -- automatically created and used. ffProfile :: Browser -> Maybe (PreparedProfile Firefox) -- | Firefox logging preference ffLogPref :: Browser -> LogLevel -- | Server-side path to Firefox binary. If Nothing, use a sensible -- system-based default. ffBinary :: Browser -> Maybe FilePath Chrome :: Maybe String -> Maybe FilePath -> [String] -> [ChromeExtension] -> Browser -- | Version of the Chrome Webdriver server server to use -- -- for more information on chromedriver see -- http://code.google.com/p/selenium/wiki/ChromeDriver chromeDriverVersion :: Browser -> Maybe String -- | Server-side path to Chrome binary. If Nothing, use a sensible -- system-based default. chromeBinary :: Browser -> Maybe FilePath -- | A list of command-line options to pass to the Chrome binary. chromeOptions :: Browser -> [String] -- | A list of extensions to use. chromeExtensions :: Browser -> [ChromeExtension] IE :: Bool -> Bool -> Maybe Text -> IEElementScrollBehavior -> Bool -> Bool -> Bool -> Integer -> Maybe FilePath -> IELogLevel -> Maybe Text -> Maybe Text -> Bool -> Bool -> Maybe Text -> Browser -- | Whether to skip the protected mode check. If set, tests may become -- flaky, unresponsive, or browsers may hang. If not set, and protected -- mode settings are not the same for all zones, an exception will be -- thrown on driver construction. ieIgnoreProtectedModeSettings :: Browser -> Bool -- | Indicates whether to skip the check that the browser's zoom level is -- set to 100%. Value is set to false by default. ieIgnoreZoomSetting :: Browser -> Bool -- | Allows the user to specify the initial URL loaded when IE starts. -- Intended to be used with ignoreProtectedModeSettings to allow the user -- to initialize IE in the proper Protected Mode zone. Using this -- capability may cause browser instability or flaky and unresponsive -- code. Only "best effort" support is provided when using this -- capability. ieInitialBrowserUrl :: Browser -> Maybe Text -- | Allows the user to specify whether elements are scrolled into the -- viewport for interaction to align with the top or bottom of the -- viewport. The default value is to align with the top of the viewport. ieElementScrollBehavior :: Browser -> IEElementScrollBehavior -- | Determines whether persistent hovering is enabled (true by default). -- Persistent hovering is achieved by continuously firing mouse over -- events at the last location the mouse cursor has been moved to. ieEnablePersistentHover :: Browser -> Bool -- | Determines whether the driver should attempt to remove obsolete -- elements from the element cache on page navigation (true by default). -- This is to help manage the IE driver's memory footprint , removing -- references to invalid elements. ieEnableElementCacheCleanup :: Browser -> Bool -- | Determines whether to require that the IE window have focus before -- performing any user interaction operations (mouse or keyboard events). -- This capability is false by default, but delivers much more accurate -- native events interactions. ieRequireWindowFocus :: Browser -> Bool -- | The timeout, in milliseconds, that the driver will attempt to locate -- and attach to a newly opened instance of Internet Explorer . The -- default is zero, which indicates waiting indefinitely. ieBrowserAttachTimeout :: Browser -> Integer -- | The path to file where server should write log messages to. By default -- it writes to stdout. ieLogFile :: Browser -> Maybe FilePath -- | The log level used by the server. Defaults to IELogFatal ieLogLevel :: Browser -> IELogLevel -- | The address of the host adapter on which the server will listen for -- commands. ieHost :: Browser -> Maybe Text -- | The path to the directory used to extract supporting files used by the -- server. Defaults to the TEMP directory if not specified. ieExtractPath :: Browser -> Maybe Text -- | Suppresses diagnostic output when the server is started. ieSilent :: Browser -> Bool -- | Forces launching Internet Explorer using the CreateProcess API. If -- this option is not specified, IE is launched using the IELaunchURL, if -- it is available. For IE 8 and above, this option requires the -- TabProcGrowth registry value to be set to 0. ieForceCreateProcess :: Browser -> Bool -- | Specifies command-line switches with which to launch Internet -- Explorer. This is only valid when used with the forceCreateProcess. ieSwitches :: Browser -> Maybe Text Opera :: Maybe FilePath -> Maybe String -> Bool -> Bool -> Bool -> Maybe Int -> Maybe FilePath -> Maybe Word16 -> Maybe String -> Maybe String -> Maybe FilePath -> LogLevel -> Browser -- | Server-side path to the Opera binary operaBinary :: Browser -> Maybe FilePath -- | Which Opera product we're using, e.g. "desktop", "core" operaProduct :: Browser -> Maybe String -- | Whether the Opera instance should stay open after we close the -- session. If false, closing the session closes the browser. operaDetach :: Browser -> Bool -- | Whether to auto-start the Opera binary. If false, OperaDriver will -- wait for a connection from the browser. By default this is True. operaAutoStart :: Browser -> Bool -- | Whether to use Opera's alternative implicit wait implementation. It -- will use an in-browser heuristic to guess when a page has finished -- loading. This feature is experimental, and disabled by default. operaIdle :: Browser -> Bool -- | (*nix only) which X display to use. operaDisplay :: Browser -> Maybe Int -- | Path to the launcher binary to use. The launcher is a gateway between -- OperaDriver and the Opera browser. If Nothing, OperaDriver will use -- the launcher supplied with the package. operaLauncher :: Browser -> Maybe FilePath -- | The port we should use to connect to Opera. If Just 0 , use a random -- port. If Nothing, use the default Opera port. The default opera -- constructor uses Just 0, since Nothing is likely to cause "address -- already in use" errors. operaPort :: Browser -> Maybe Word16 -- | The host Opera should connect to. Unless you're starting Opera -- manually you won't need this. operaHost :: Browser -> Maybe String -- | Command-line arguments to pass to Opera. operaOptions :: Browser -> Maybe String -- | Where to send the log output. If Nothing, logging is disabled. operaLogFile :: Browser -> Maybe FilePath -- | Log level preference. Defaults to LogInfo operaLogPref :: Browser -> LogLevel HTMLUnit :: Browser IPhone :: Browser IPad :: Browser Android :: Browser -- | some other browser, specified by a string name Browser :: Text -> Browser -- | Default Firefox settings. All Maybe fields are set to Nothing. -- ffLogPref is set to LogInfo. firefox :: Browser -- | Default Chrome settings. All Maybe fields are set to Nothing, no -- options are specified, and no extensions are used. chrome :: Browser -- | Default IE settings. See the IE constructor for more details on -- individual defaults ie :: Browser -- | Default Opera settings. See the Opera constructor for more -- details on individual defaults. opera :: Browser iPhone :: Browser iPad :: Browser android :: Browser -- | Indicates a log verbosity level. Used in Firefox and -- Opera configuration. data LogLevel LogOff :: LogLevel LogSevere :: LogLevel LogWarning :: LogLevel LogInfo :: LogLevel LogConfig :: LogLevel LogFine :: LogLevel LogFiner :: LogLevel LogFinest :: LogLevel LogAll :: LogLevel -- | Logging levels for Internet Explorer data IELogLevel IELogTrace :: IELogLevel IELogDebug :: IELogLevel IELogInfo :: IELogLevel IELogWarn :: IELogLevel IELogError :: IELogLevel IELogFatal :: IELogLevel -- | Specifies how elements scroll into the viewport. (see -- ieElementScrollBehavior) data IEElementScrollBehavior AlignTop :: IEElementScrollBehavior AlignBottom :: IEElementScrollBehavior -- | An opaque identifier for a web page element. newtype Element Element :: Text -> Element -- | An opaque identifier for a browser window newtype WindowHandle WindowHandle :: Text -> WindowHandle -- | A special WindowHandle that always refers to the currently -- focused window. This is also used by the Default instance. currentWindow :: WindowHandle -- | Specifies element(s) within a DOM tree using various selection -- methods. data Selector ById :: Text -> Selector ByName :: Text -> Selector -- | (Note: multiple classes are not allowed. For more control, use -- ByCSS) ByClass :: Text -> Selector ByTag :: Text -> Selector ByLinkText :: Text -> Selector ByPartialLinkText :: Text -> Selector ByCSS :: Text -> Selector ByXPath :: Text -> Selector -- | An existential wrapper for any ToJSON instance. This allows us -- to pass parameters of many different types to Javascript code. data JSArg JSArg :: a -> JSArg -- | Specifies the frame used by focusFrame data FrameSelector WithIndex :: Integer -> FrameSelector -- | focus on a frame by name or ID WithName :: Text -> FrameSelector -- | focus on a frame Element WithElement :: Element -> FrameSelector -- | focus on the first frame, or the main document if iframes are used. DefaultFrame :: FrameSelector -- | 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. data Cookie Cookie :: Text -> Text -> Maybe Text -> Maybe Text -> Maybe Bool -> Maybe Integer -> Cookie cookName :: Cookie -> Text cookValue :: Cookie -> Text -- | path of this cookie. if Nothing, defaults to / cookPath :: Cookie -> Maybe Text -- | domain of this cookie. if Nothing, the current pages domain is used cookDomain :: Cookie -> Maybe Text -- | Is this cookie secure? cookSecure :: Cookie -> Maybe Bool -- | Expiry date expressed as seconds since the Unix epoch Nothing -- indicates that the cookie never expires cookExpiry :: Cookie -> Maybe Integer -- | 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. mkCookie :: Text -> Text -> Cookie -- | A screen orientation data Orientation Landscape :: Orientation Portrait :: Orientation -- | A mouse button data MouseButton LeftButton :: MouseButton MiddleButton :: MouseButton RightButton :: MouseButton -- | An HTML 5 storage type data WebStorageType LocalStorage :: WebStorageType SessionStorage :: WebStorageType type LogType = String -- | A record that represents a single log entry. data LogEntry LogEntry :: Integer -> LogLevel -> Text -> LogEntry -- | timestamp for the log entry. The standard does not specify the epoch -- or the unit of time. logTime :: LogEntry -> Integer -- | log verbosity level logLevel :: LogEntry -> LogLevel logMsg :: LogEntry -> Text data ApplicationCacheStatus Uncached :: ApplicationCacheStatus Idle :: ApplicationCacheStatus Checking :: ApplicationCacheStatus Downloading :: ApplicationCacheStatus UpdateReady :: ApplicationCacheStatus Obsolete :: ApplicationCacheStatus -- | An invalid URL was given newtype InvalidURL InvalidURL :: String -> InvalidURL -- | A command requiring a session ID was attempted when no session ID was -- available. newtype NoSessionId NoSessionId :: String -> NoSessionId -- | An error occured when parsing a JSON value. newtype BadJSON BadJSON :: String -> BadJSON -- | An unexpected HTTP status was sent by the server. data HTTPStatusUnknown HTTPStatusUnknown :: Int -> String -> HTTPStatusUnknown -- | HTTP connection errors. data HTTPConnError HTTPConnError :: String -> Int -> HTTPConnError -- | A command was sent to the WebDriver server that it didn't recognize. newtype UnknownCommand UnknownCommand :: String -> UnknownCommand -- | A server-side exception occured newtype ServerError ServerError :: String -> ServerError -- | This exception encapsulates a broad variety of exceptions that can -- occur when a command fails. data FailedCommand FailedCommand :: FailedCommandType -> FailedCommandInfo -> FailedCommand -- | The type of failed command exception that occured. data FailedCommandType NoSuchElement :: FailedCommandType NoSuchFrame :: FailedCommandType UnknownFrame :: FailedCommandType StaleElementReference :: FailedCommandType ElementNotVisible :: FailedCommandType InvalidElementState :: FailedCommandType UnknownError :: FailedCommandType ElementIsNotSelectable :: FailedCommandType JavascriptError :: FailedCommandType XPathLookupError :: FailedCommandType Timeout :: FailedCommandType NoSuchWindow :: FailedCommandType InvalidCookieDomain :: FailedCommandType UnableToSetCookie :: FailedCommandType UnexpectedAlertOpen :: FailedCommandType NoAlertOpen :: FailedCommandType ScriptTimeout :: FailedCommandType InvalidElementCoordinates :: FailedCommandType IMENotAvailable :: FailedCommandType IMEEngineActivationFailed :: FailedCommandType InvalidSelector :: FailedCommandType SessionNotCreated :: FailedCommandType MoveTargetOutOfBounds :: FailedCommandType InvalidXPathSelector :: FailedCommandType InvalidXPathSelectorReturnType :: FailedCommandType -- | Detailed information about the failed command provided by the server. data FailedCommandInfo FailedCommandInfo :: String -> Maybe WDSession -> Maybe ByteString -> Maybe String -> [StackFrame] -> FailedCommandInfo -- | The error message. errMsg :: FailedCommandInfo -> String -- | The session associated with the exception. errSess :: FailedCommandInfo -> Maybe WDSession -- | A screen shot of the focused window when the exception occured, if -- provided. errScreen :: FailedCommandInfo -> Maybe ByteString -- | The "class" in which the exception was raised, if provided. errClass :: FailedCommandInfo -> Maybe String -- | A stack trace of the exception. errStack :: FailedCommandInfo -> [StackFrame] -- | An individual stack frame from the stack trace provided by the server -- during a FailedCommand. data StackFrame StackFrame :: String -> String -> String -> Word -> StackFrame sfFileName :: StackFrame -> String sfClassName :: StackFrame -> String sfMethodName :: StackFrame -> String sfLineNumber :: StackFrame -> Word -- | Constructs a FailedCommandInfo from only an error message. mkFailedCommandInfo :: WDSessionState s => String -> s FailedCommandInfo -- | Convenience function to throw a FailedCommand locally with no -- server-side info present. failedCommand :: WDSessionState s => FailedCommandType -> String -> s a -- | This module serves as the top-level interface to the Haskell WebDriver -- bindings, providing most of the functionality you're likely to want. module Test.WebDriver -- | A monadic interface to the WebDriver server. This monad is simply a -- state monad transformer over IO, threading session information -- between sequential webdriver commands newtype WD a WD :: (StateT WDSession IO a) -> WD a -- | WebDriver session configuration data WDConfig WDConfig :: String -> Int -> RequestHeaders -> Capabilities -> Bool -> String -> Maybe Manager -> WDConfig -- | Host name of the WebDriver server for this session (default 127.0.0.1) wdHost :: WDConfig -> String -- | Port number of the server (default 4444) wdPort :: WDConfig -> Int -- | Additional request headers to send to the server during session -- creation (default []) wdRequestHeaders :: WDConfig -> RequestHeaders -- | Capabilities to use for this session wdCapabilities :: WDConfig -> Capabilities -- | Whether or not we should keep a history of HTTP requests/responses -- -- By default, only the last request/response pair is stored (O(1) heap -- consumption). Enable this option for more detailed debugging info for -- HTTP requests. wdKeepSessHist :: WDConfig -> Bool -- | Base path for all API requests (default "wdhub") wdBasePath :: WDConfig -> String -- | Use the given http-client Manager instead of the default wdHTTPManager :: WDConfig -> Maybe Manager -- | 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. defaultConfig :: WDConfig -- | Executes a WD computation within the IO monad, using the -- given WDSession. runWD :: WDSession -> WD a -> IO a -- | 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 runSession :: WDConfig -> WD a -> IO a -- | 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. withSession :: WDSession -> WD a -> WD a -- | A finalizer ensuring that the session is always closed at the end of -- the given WD action, regardless of any exceptions. finallyClose :: WebDriver wd => wd a -> wd a -- | Exception handler that closes the session when an asynchronous -- exception is thrown, but otherwise leaves the session open if the -- action was successful. closeOnException :: WebDriver wd => wd a -> wd a -- | Prints a history of API requests to stdout after computing the given -- action. dumpSessionHistory :: (MonadIO wd, WebDriver wd) => wd a -> wd a -- | A structure describing the capabilities of a session. This record -- serves dual roles. -- -- data Capabilities Capabilities :: Browser -> Maybe String -> Platform -> ProxyType -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe UnexpectedAlertBehavior -> [Pair] -> Capabilities -- | Browser choice and browser specific settings. browser :: Capabilities -> Browser -- | Browser version to use. version :: Capabilities -> Maybe String -- | Platform on which the browser should run. platform :: Capabilities -> Platform -- | Proxy configuration settings. proxy :: Capabilities -> ProxyType -- | Whether the session supports executing JavaScript via -- executeJS and asyncJS. javascriptEnabled :: Capabilities -> Maybe Bool -- | Whether the session supports taking screenshots of the current page -- with the screenshot command takesScreenshot :: Capabilities -> Maybe Bool -- | Whether the session can interact with modal popups, such as -- window.alert and window.confirm via acceptAlerts, -- dismissAlerts, etc. handlesAlerts :: Capabilities -> Maybe Bool -- | Whether the session can interact with database storage. databaseEnabled :: Capabilities -> Maybe Bool -- | Whether the session can set and query the browser's location context -- with setLocation and getLocation. locationContextEnabled :: Capabilities -> Maybe Bool -- | Whether the session can interact with the application cache . applicationCacheEnabled :: Capabilities -> Maybe Bool -- | Whether the session can query for the browser's connectivity and -- disable it if desired browserConnectionEnabled :: Capabilities -> Maybe Bool -- | Whether the session supports CSS selectors when searching for -- elements. cssSelectorsEnabled :: Capabilities -> Maybe Bool -- | Whether Web Storage (getKey, setKey, etc) support is -- enabled webStorageEnabled :: Capabilities -> Maybe Bool -- | Whether the session can rotate the current page's current layout -- between Portrait and Landscape orientations. rotatable :: Capabilities -> Maybe Bool -- | Whether the session should accept all SSL certs by default acceptSSLCerts :: Capabilities -> Maybe Bool -- | Whether the session is capable of generating native OS events when -- simulating user input. nativeEvents :: Capabilities -> Maybe Bool -- | How the session should handle unexpected alerts. unexpectedAlertBehavior :: Capabilities -> Maybe UnexpectedAlertBehavior -- | A list of (Text, Value) pairs specifying additional -- non-standard capabilities. additionalCaps :: Capabilities -> [Pair] -- | 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 -- capabilities are set to Nothing (no preference). defaultCaps :: Capabilities -- | Same as defaultCaps, but with all Maybe Bool -- capabilities set to Just True. allCaps :: Capabilities -- | Represents platform options supported by WebDriver. The value Any -- represents no preference. data Platform Windows :: Platform XP :: Platform Vista :: Platform Mac :: Platform Linux :: Platform Unix :: Platform Any :: Platform -- | Available settings for the proxy Capabilities field data ProxyType NoProxy :: ProxyType UseSystemSettings :: ProxyType AutoDetect :: ProxyType -- | Use a proxy auto-config file specified by URL PAC :: String -> ProxyType autoConfigUrl :: ProxyType -> String -- | Manually specify proxy hosts as hostname:port strings. Note that -- behavior is undefined for empty strings. Manual :: String -> String -> String -> ProxyType ftpProxy :: ProxyType -> String sslProxy :: ProxyType -> String httpProxy :: ProxyType -> String -- | 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. data Browser Firefox :: Maybe (PreparedProfile Firefox) -> LogLevel -> Maybe FilePath -> Browser -- | The firefox profile to use. If Nothing, a default temporary profile is -- automatically created and used. ffProfile :: Browser -> Maybe (PreparedProfile Firefox) -- | Firefox logging preference ffLogPref :: Browser -> LogLevel -- | Server-side path to Firefox binary. If Nothing, use a sensible -- system-based default. ffBinary :: Browser -> Maybe FilePath Chrome :: Maybe String -> Maybe FilePath -> [String] -> [ChromeExtension] -> Browser -- | Version of the Chrome Webdriver server server to use -- -- for more information on chromedriver see -- http://code.google.com/p/selenium/wiki/ChromeDriver chromeDriverVersion :: Browser -> Maybe String -- | Server-side path to Chrome binary. If Nothing, use a sensible -- system-based default. chromeBinary :: Browser -> Maybe FilePath -- | A list of command-line options to pass to the Chrome binary. chromeOptions :: Browser -> [String] -- | A list of extensions to use. chromeExtensions :: Browser -> [ChromeExtension] IE :: Bool -> Bool -> Maybe Text -> IEElementScrollBehavior -> Bool -> Bool -> Bool -> Integer -> Maybe FilePath -> IELogLevel -> Maybe Text -> Maybe Text -> Bool -> Bool -> Maybe Text -> Browser -- | Whether to skip the protected mode check. If set, tests may become -- flaky, unresponsive, or browsers may hang. If not set, and protected -- mode settings are not the same for all zones, an exception will be -- thrown on driver construction. ieIgnoreProtectedModeSettings :: Browser -> Bool -- | Indicates whether to skip the check that the browser's zoom level is -- set to 100%. Value is set to false by default. ieIgnoreZoomSetting :: Browser -> Bool -- | Allows the user to specify the initial URL loaded when IE starts. -- Intended to be used with ignoreProtectedModeSettings to allow the user -- to initialize IE in the proper Protected Mode zone. Using this -- capability may cause browser instability or flaky and unresponsive -- code. Only "best effort" support is provided when using this -- capability. ieInitialBrowserUrl :: Browser -> Maybe Text -- | Allows the user to specify whether elements are scrolled into the -- viewport for interaction to align with the top or bottom of the -- viewport. The default value is to align with the top of the viewport. ieElementScrollBehavior :: Browser -> IEElementScrollBehavior -- | Determines whether persistent hovering is enabled (true by default). -- Persistent hovering is achieved by continuously firing mouse over -- events at the last location the mouse cursor has been moved to. ieEnablePersistentHover :: Browser -> Bool -- | Determines whether the driver should attempt to remove obsolete -- elements from the element cache on page navigation (true by default). -- This is to help manage the IE driver's memory footprint , removing -- references to invalid elements. ieEnableElementCacheCleanup :: Browser -> Bool -- | Determines whether to require that the IE window have focus before -- performing any user interaction operations (mouse or keyboard events). -- This capability is false by default, but delivers much more accurate -- native events interactions. ieRequireWindowFocus :: Browser -> Bool -- | The timeout, in milliseconds, that the driver will attempt to locate -- and attach to a newly opened instance of Internet Explorer . The -- default is zero, which indicates waiting indefinitely. ieBrowserAttachTimeout :: Browser -> Integer -- | The path to file where server should write log messages to. By default -- it writes to stdout. ieLogFile :: Browser -> Maybe FilePath -- | The log level used by the server. Defaults to IELogFatal ieLogLevel :: Browser -> IELogLevel -- | The address of the host adapter on which the server will listen for -- commands. ieHost :: Browser -> Maybe Text -- | The path to the directory used to extract supporting files used by the -- server. Defaults to the TEMP directory if not specified. ieExtractPath :: Browser -> Maybe Text -- | Suppresses diagnostic output when the server is started. ieSilent :: Browser -> Bool -- | Forces launching Internet Explorer using the CreateProcess API. If -- this option is not specified, IE is launched using the IELaunchURL, if -- it is available. For IE 8 and above, this option requires the -- TabProcGrowth registry value to be set to 0. ieForceCreateProcess :: Browser -> Bool -- | Specifies command-line switches with which to launch Internet -- Explorer. This is only valid when used with the forceCreateProcess. ieSwitches :: Browser -> Maybe Text Opera :: Maybe FilePath -> Maybe String -> Bool -> Bool -> Bool -> Maybe Int -> Maybe FilePath -> Maybe Word16 -> Maybe String -> Maybe String -> Maybe FilePath -> LogLevel -> Browser -- | Server-side path to the Opera binary operaBinary :: Browser -> Maybe FilePath -- | Which Opera product we're using, e.g. "desktop", "core" operaProduct :: Browser -> Maybe String -- | Whether the Opera instance should stay open after we close the -- session. If false, closing the session closes the browser. operaDetach :: Browser -> Bool -- | Whether to auto-start the Opera binary. If false, OperaDriver will -- wait for a connection from the browser. By default this is True. operaAutoStart :: Browser -> Bool -- | Whether to use Opera's alternative implicit wait implementation. It -- will use an in-browser heuristic to guess when a page has finished -- loading. This feature is experimental, and disabled by default. operaIdle :: Browser -> Bool -- | (*nix only) which X display to use. operaDisplay :: Browser -> Maybe Int -- | Path to the launcher binary to use. The launcher is a gateway between -- OperaDriver and the Opera browser. If Nothing, OperaDriver will use -- the launcher supplied with the package. operaLauncher :: Browser -> Maybe FilePath -- | The port we should use to connect to Opera. If Just 0 , use a random -- port. If Nothing, use the default Opera port. The default opera -- constructor uses Just 0, since Nothing is likely to cause "address -- already in use" errors. operaPort :: Browser -> Maybe Word16 -- | The host Opera should connect to. Unless you're starting Opera -- manually you won't need this. operaHost :: Browser -> Maybe String -- | Command-line arguments to pass to Opera. operaOptions :: Browser -> Maybe String -- | Where to send the log output. If Nothing, logging is disabled. operaLogFile :: Browser -> Maybe FilePath -- | Log level preference. Defaults to LogInfo operaLogPref :: Browser -> LogLevel HTMLUnit :: Browser IPhone :: Browser IPad :: Browser Android :: Browser -- | some other browser, specified by a string name Browser :: Text -> Browser -- | Indicates a log verbosity level. Used in Firefox and -- Opera configuration. data LogLevel LogOff :: LogLevel LogSevere :: LogLevel LogWarning :: LogLevel LogInfo :: LogLevel LogConfig :: LogLevel LogFine :: LogLevel LogFiner :: LogLevel LogFinest :: LogLevel LogAll :: LogLevel -- | Default Firefox settings. All Maybe fields are set to Nothing. -- ffLogPref is set to LogInfo. firefox :: Browser -- | Default Chrome settings. All Maybe fields are set to Nothing, no -- options are specified, and no extensions are used. chrome :: Browser -- | Default IE settings. See the IE constructor for more details on -- individual defaults ie :: Browser -- | Default Opera settings. See the Opera constructor for more -- details on individual defaults. opera :: Browser iPhone :: Browser iPad :: Browser android :: Browser