{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE CPP #-}

module Test.WebDriver.Capabilities where

import Test.WebDriver.Chrome.Extension
import Test.WebDriver.Firefox.Profile
import Test.WebDriver.JSON

import Data.Aeson
import Data.Aeson.Types (Parser, typeMismatch, Pair)

import Data.Text (Text, toLower, toUpper)
import Data.Default.Class (Default(..))
import Data.Word (Word16)
import Data.Maybe (fromMaybe, catMaybes)
import Data.String (fromString)

import Control.Applicative
import Control.Exception.Lifted (throw)

import Prelude -- hides some "unused import" warnings

#if MIN_VERSION_aeson(2,0,0)
import qualified Data.Aeson.KeyMap          as HM (delete, toList, empty)
#else
import qualified Data.HashMap.Strict        as HM (delete, toList, empty)
#endif


-- |A typeclass for readable 'Capabilities'
class GetCapabilities t where
  getCaps :: t -> Capabilities

instance GetCapabilities Capabilities where
  getCaps :: Capabilities -> Capabilities
getCaps = forall a. a -> a
id

-- |A typeclass for writable 'Capabilities'
class SetCapabilities t where
  setCaps :: Capabilities -> t -> t

-- |Read/write 'Capabilities'
type HasCapabilities t = (GetCapabilities t, SetCapabilities t)

-- |Modifies the 'wdCapabilities' field of a 'WDConfig' by applying the given function. Overloaded to work with any 'HasCapabilities' instance.
modifyCaps :: HasCapabilities t => (Capabilities -> Capabilities) -> t -> t
modifyCaps :: forall t.
HasCapabilities t =>
(Capabilities -> Capabilities) -> t -> t
modifyCaps Capabilities -> Capabilities
f t
c = forall t. SetCapabilities t => Capabilities -> t -> t
setCaps (Capabilities -> Capabilities
f (forall t. GetCapabilities t => t -> Capabilities
getCaps t
c)) t
c

-- |A helper function for setting the 'browser' capability of a 'HasCapabilities' instance
useBrowser :: HasCapabilities t => Browser -> t -> t
useBrowser :: forall t. HasCapabilities t => Browser -> t -> t
useBrowser Browser
b = forall t.
HasCapabilities t =>
(Capabilities -> Capabilities) -> t -> t
modifyCaps forall a b. (a -> b) -> a -> b
$ \Capabilities
c -> Capabilities
c { browser :: Browser
browser = Browser
b }

-- |A helper function for setting the 'version' capability of a 'HasCapabilities' instance
useVersion :: HasCapabilities t => String -> t -> t
useVersion :: forall t. HasCapabilities t => String -> t -> t
useVersion String
v = forall t.
HasCapabilities t =>
(Capabilities -> Capabilities) -> t -> t
modifyCaps forall a b. (a -> b) -> a -> b
$ \Capabilities
c -> Capabilities
c { version :: Maybe String
version = forall a. a -> Maybe a
Just String
v }

-- |A helper function for setting the 'platform' capability of a 'HasCapabilities' instance
usePlatform :: HasCapabilities t => Platform -> t -> t
usePlatform :: forall t. HasCapabilities t => Platform -> t -> t
usePlatform Platform
p = forall t.
HasCapabilities t =>
(Capabilities -> Capabilities) -> t -> t
modifyCaps forall a b. (a -> b) -> a -> b
$ \Capabilities
c -> Capabilities
c { platform :: Platform
platform = Platform
p }

-- |A helper function for setting the 'useProxy' capability of a 'HasCapabilities' instance
useProxy :: HasCapabilities t => ProxyType -> t -> t
useProxy :: forall t. HasCapabilities t => ProxyType -> t -> t
useProxy ProxyType
p = forall t.
HasCapabilities t =>
(Capabilities -> Capabilities) -> t -> t
modifyCaps forall a b. (a -> b) -> a -> b
$ \Capabilities
c -> Capabilities
c { proxy :: ProxyType
proxy = ProxyType
p }


{- |A structure describing the capabilities of a session. This record
serves dual roles.

* It's used to specify the desired capabilities for a session before
it's created. In this usage, fields that are set to Nothing indicate
that we have no preference for that capability.

* When received from the server , it's used to
describe the actual capabilities given to us by the WebDriver
server. Here a value of Nothing indicates that the server doesn't
support the capability. Thus, for Maybe Bool fields, both Nothing and
Just False indicate a lack of support for the desired capability.
-}
data Capabilities =
  Capabilities { -- |Browser choice and browser specific settings.
                 Capabilities -> Browser
browser                  :: Browser
                 -- |Browser version to use.
               , Capabilities -> Maybe String
version                  :: Maybe String
                 -- |Platform on which the browser should run.
               , Capabilities -> Platform
platform                 :: Platform
                 -- |Proxy configuration settings.
               , Capabilities -> ProxyType
proxy                    :: ProxyType
                 -- |Whether the session supports executing JavaScript via
                 -- 'executeJS' and 'asyncJS'.
               , Capabilities -> Maybe Bool
javascriptEnabled        :: Maybe Bool
                 -- |Whether the session supports taking screenshots of the
                 -- current page with the 'screenshot' command
               , Capabilities -> Maybe Bool
takesScreenshot          :: Maybe Bool
                 -- |Whether the session can interact with modal popups,
                 -- such as window.alert and window.confirm via
                 -- 'acceptAlerts', 'dismissAlerts', etc.
               , Capabilities -> Maybe Bool
handlesAlerts            :: Maybe Bool
                 -- |Whether the session can interact with database storage.
               , Capabilities -> Maybe Bool
databaseEnabled          :: Maybe Bool
                 -- |Whether the session can set and query the browser's
                 -- location context with 'setLocation' and 'getLocation'.
               , Capabilities -> Maybe Bool
locationContextEnabled   :: Maybe Bool
                 -- |Whether the session can interact with the application cache
                 -- .
               , Capabilities -> Maybe Bool
applicationCacheEnabled  :: Maybe Bool
                 -- |Whether the session can query for the browser's
                 -- connectivity and disable it if desired
               , Capabilities -> Maybe Bool
browserConnectionEnabled :: Maybe Bool
                 -- |Whether the session supports CSS selectors when searching
                 -- for elements.
               , Capabilities -> Maybe Bool
cssSelectorsEnabled      :: Maybe Bool
                 -- |Whether Web Storage ('getKey', 'setKey', etc) support is
                 -- enabled
               , Capabilities -> Maybe Bool
webStorageEnabled        :: Maybe Bool
                 -- |Whether the session can rotate the current page's current
                 -- layout between 'Portrait' and 'Landscape' orientations.
               , Capabilities -> Maybe Bool
rotatable                :: Maybe Bool
                 -- |Whether the session should accept all SSL certs by default
               , Capabilities -> Maybe Bool
acceptSSLCerts           :: Maybe Bool
                 -- |Whether the session is capable of generating native OS
                 -- events when simulating user input.
               , Capabilities -> Maybe Bool
nativeEvents             :: Maybe Bool
                 -- |How the session should handle unexpected alerts.
               , Capabilities -> Maybe UnexpectedAlertBehavior
unexpectedAlertBehavior :: Maybe UnexpectedAlertBehavior
                 -- |A list of ('Text', 'Value') pairs specifying additional non-standard capabilities.
               , Capabilities -> [Pair]
additionalCaps           :: [Pair]
               } deriving (Capabilities -> Capabilities -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Capabilities -> Capabilities -> Bool
$c/= :: Capabilities -> Capabilities -> Bool
== :: Capabilities -> Capabilities -> Bool
$c== :: Capabilities -> Capabilities -> Bool
Eq, Int -> Capabilities -> ShowS
[Capabilities] -> ShowS
Capabilities -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Capabilities] -> ShowS
$cshowList :: [Capabilities] -> ShowS
show :: Capabilities -> String
$cshow :: Capabilities -> String
showsPrec :: Int -> Capabilities -> ShowS
$cshowsPrec :: Int -> Capabilities -> ShowS
Show)

instance Default Capabilities where
  def :: Capabilities
def = Capabilities { browser :: Browser
browser = Browser
firefox
                     , version :: Maybe String
version = forall a. Maybe a
Nothing
                     , platform :: Platform
platform = Platform
Any
                     , javascriptEnabled :: Maybe Bool
javascriptEnabled = forall a. Maybe a
Nothing
                     , takesScreenshot :: Maybe Bool
takesScreenshot = forall a. Maybe a
Nothing
                     , handlesAlerts :: Maybe Bool
handlesAlerts = forall a. Maybe a
Nothing
                     , databaseEnabled :: Maybe Bool
databaseEnabled = forall a. Maybe a
Nothing
                     , locationContextEnabled :: Maybe Bool
locationContextEnabled = forall a. Maybe a
Nothing
                     , applicationCacheEnabled :: Maybe Bool
applicationCacheEnabled = forall a. Maybe a
Nothing
                     , browserConnectionEnabled :: Maybe Bool
browserConnectionEnabled = forall a. Maybe a
Nothing
                     , cssSelectorsEnabled :: Maybe Bool
cssSelectorsEnabled = forall a. Maybe a
Nothing
                     , webStorageEnabled :: Maybe Bool
webStorageEnabled = forall a. Maybe a
Nothing
                     , rotatable :: Maybe Bool
rotatable = forall a. Maybe a
Nothing
                     , acceptSSLCerts :: Maybe Bool
acceptSSLCerts = forall a. Maybe a
Nothing
                     , nativeEvents :: Maybe Bool
nativeEvents = forall a. Maybe a
Nothing
                     , proxy :: ProxyType
proxy = ProxyType
UseSystemSettings
                     , unexpectedAlertBehavior :: Maybe UnexpectedAlertBehavior
unexpectedAlertBehavior = forall a. Maybe a
Nothing
                     , additionalCaps :: [Pair]
additionalCaps = []
                     }

-- |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
defaultCaps :: Capabilities
defaultCaps = forall a. Default a => a
def

-- |Same as 'defaultCaps', but with all 'Maybe' 'Bool' capabilities set to
-- 'Just' 'True'.
allCaps :: Capabilities
allCaps :: Capabilities
allCaps = Capabilities
defaultCaps { javascriptEnabled :: Maybe Bool
javascriptEnabled = forall a. a -> Maybe a
Just Bool
True
                      , takesScreenshot :: Maybe Bool
takesScreenshot = forall a. a -> Maybe a
Just Bool
True
                      , handlesAlerts :: Maybe Bool
handlesAlerts = forall a. a -> Maybe a
Just Bool
True
                      , databaseEnabled :: Maybe Bool
databaseEnabled = forall a. a -> Maybe a
Just Bool
True
                      , locationContextEnabled :: Maybe Bool
locationContextEnabled = forall a. a -> Maybe a
Just Bool
True
                      , applicationCacheEnabled :: Maybe Bool
applicationCacheEnabled = forall a. a -> Maybe a
Just Bool
True
                      , browserConnectionEnabled :: Maybe Bool
browserConnectionEnabled = forall a. a -> Maybe a
Just Bool
True
                      , cssSelectorsEnabled :: Maybe Bool
cssSelectorsEnabled = forall a. a -> Maybe a
Just Bool
True
                      , webStorageEnabled :: Maybe Bool
webStorageEnabled = forall a. a -> Maybe a
Just Bool
True
                      , rotatable :: Maybe Bool
rotatable = forall a. a -> Maybe a
Just Bool
True
                      , acceptSSLCerts :: Maybe Bool
acceptSSLCerts = forall a. a -> Maybe a
Just Bool
True
                      , nativeEvents :: Maybe Bool
nativeEvents = forall a. a -> Maybe a
Just Bool
True
                      }

instance ToJSON Capabilities where
  toJSON :: Capabilities -> Value
toJSON Capabilities{[Pair]
Maybe Bool
Maybe String
Maybe UnexpectedAlertBehavior
ProxyType
Platform
Browser
additionalCaps :: [Pair]
unexpectedAlertBehavior :: Maybe UnexpectedAlertBehavior
nativeEvents :: Maybe Bool
acceptSSLCerts :: Maybe Bool
rotatable :: Maybe Bool
webStorageEnabled :: Maybe Bool
cssSelectorsEnabled :: Maybe Bool
browserConnectionEnabled :: Maybe Bool
applicationCacheEnabled :: Maybe Bool
locationContextEnabled :: Maybe Bool
databaseEnabled :: Maybe Bool
handlesAlerts :: Maybe Bool
takesScreenshot :: Maybe Bool
javascriptEnabled :: Maybe Bool
proxy :: ProxyType
platform :: Platform
version :: Maybe String
browser :: Browser
additionalCaps :: Capabilities -> [Pair]
unexpectedAlertBehavior :: Capabilities -> Maybe UnexpectedAlertBehavior
nativeEvents :: Capabilities -> Maybe Bool
acceptSSLCerts :: Capabilities -> Maybe Bool
rotatable :: Capabilities -> Maybe Bool
webStorageEnabled :: Capabilities -> Maybe Bool
cssSelectorsEnabled :: Capabilities -> Maybe Bool
browserConnectionEnabled :: Capabilities -> Maybe Bool
applicationCacheEnabled :: Capabilities -> Maybe Bool
locationContextEnabled :: Capabilities -> Maybe Bool
databaseEnabled :: Capabilities -> Maybe Bool
handlesAlerts :: Capabilities -> Maybe Bool
takesScreenshot :: Capabilities -> Maybe Bool
javascriptEnabled :: Capabilities -> Maybe Bool
proxy :: Capabilities -> ProxyType
platform :: Capabilities -> Platform
version :: Capabilities -> Maybe String
browser :: Capabilities -> Browser
..} =
    [Pair] -> Value
object forall a b. (a -> b) -> a -> b
$ forall a. (a -> Bool) -> [a] -> [a]
filter (\Pair
p -> forall a b. (a, b) -> b
snd Pair
p forall a. Eq a => a -> a -> Bool
/= Value
Null)
           forall a b. (a -> b) -> a -> b
$ [ Key
"browserName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Browser
browser
             , Key
"version" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe String
version
             , Key
"platform" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Platform
platform
             , Key
"proxy" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ProxyType
proxy
             , Key
"javascriptEnabled" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
javascriptEnabled
             , Key
"takesScreenshot" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
takesScreenshot
             , Key
"handlesAlerts" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
handlesAlerts
             , Key
"databaseEnabled" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
databaseEnabled
             , Key
"locationContextEnabled" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
locationContextEnabled
             , Key
"applicationCacheEnabled" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
applicationCacheEnabled
             , Key
"browserConnectionEnabled" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
browserConnectionEnabled
             , Key
"cssSelectorsEnabled" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
cssSelectorsEnabled
             , Key
"webStorageEnabled" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
webStorageEnabled
             , Key
"rotatable" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
rotatable
             , Key
"acceptSslCerts" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
acceptSSLCerts
             , Key
"nativeEvents" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
nativeEvents
             , Key
"unexpectedAlertBehavior" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe UnexpectedAlertBehavior
unexpectedAlertBehavior
             ]
    forall a. [a] -> [a] -> [a]
++ [Pair]
browserInfo
    forall a. [a] -> [a] -> [a]
++ [Pair]
additionalCaps
    where
      browserInfo :: [Pair]
browserInfo = case Browser
browser of
        Firefox {Maybe Bool
Maybe String
Maybe (PreparedProfile Firefox)
LogLevel
ffAcceptInsecureCerts :: Browser -> Maybe Bool
ffBinary :: Browser -> Maybe String
ffLogPref :: Browser -> LogLevel
ffProfile :: Browser -> Maybe (PreparedProfile Firefox)
ffAcceptInsecureCerts :: Maybe Bool
ffBinary :: Maybe String
ffLogPref :: LogLevel
ffProfile :: Maybe (PreparedProfile Firefox)
..}
          -> [Key
"firefox_profile" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe (PreparedProfile Firefox)
ffProfile
             ,Key
"loggingPrefs" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object [Key
"driver" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= LogLevel
ffLogPref]
             ,Key
"firefox_binary" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe String
ffBinary
             ,Key
"acceptInsecureCerts" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. a -> Maybe a -> a
fromMaybe Bool
False Maybe Bool
ffAcceptInsecureCerts
             ]
        Chrome {[String]
[ChromeExtension]
Maybe String
Object
chromeExperimentalOptions :: Browser -> Object
chromeExtensions :: Browser -> [ChromeExtension]
chromeOptions :: Browser -> [String]
chromeBinary :: Browser -> Maybe String
chromeDriverVersion :: Browser -> Maybe String
chromeExperimentalOptions :: Object
chromeExtensions :: [ChromeExtension]
chromeOptions :: [String]
chromeBinary :: Maybe String
chromeDriverVersion :: Maybe String
..}
          -> forall a. [Maybe a] -> [a]
catMaybes [ forall {f :: * -> *} {b} {a}.
(Functor f, KeyValue b, ToJSON a) =>
Key -> f a -> f b
opt Key
"chrome.chromedriverVersion" Maybe String
chromeDriverVersion ]
             forall a. [a] -> [a] -> [a]
++ [ Key
"chromeOptions" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object (forall a. [Maybe a] -> [a]
catMaybes
                  [ forall {f :: * -> *} {b} {a}.
(Functor f, KeyValue b, ToJSON a) =>
Key -> f a -> f b
opt Key
"binary" Maybe String
chromeBinary
                  ] forall a. [a] -> [a] -> [a]
++
                  [ Key
"args"       forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [String]
chromeOptions
                  , Key
"extensions" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [ChromeExtension]
chromeExtensions
                  ] forall a. [a] -> [a] -> [a]
++ forall v. KeyMap v -> [(Key, v)]
HM.toList Object
chromeExperimentalOptions
                )]
        IE {Bool
Integer
Maybe String
Maybe Text
IEElementScrollBehavior
IELogLevel
ieSwitches :: Browser -> Maybe Text
ieForceCreateProcess :: Browser -> Bool
ieSilent :: Browser -> Bool
ieExtractPath :: Browser -> Maybe Text
ieHost :: Browser -> Maybe Text
ieLogLevel :: Browser -> IELogLevel
ieLogFile :: Browser -> Maybe String
ieBrowserAttachTimeout :: Browser -> Integer
ieRequireWindowFocus :: Browser -> Bool
ieEnableElementCacheCleanup :: Browser -> Bool
ieEnablePersistentHover :: Browser -> Bool
ieElementScrollBehavior :: Browser -> IEElementScrollBehavior
ieInitialBrowserUrl :: Browser -> Maybe Text
ieIgnoreZoomSetting :: Browser -> Bool
ieIgnoreProtectedModeSettings :: Browser -> Bool
ieSwitches :: Maybe Text
ieForceCreateProcess :: Bool
ieSilent :: Bool
ieExtractPath :: Maybe Text
ieHost :: Maybe Text
ieLogLevel :: IELogLevel
ieLogFile :: Maybe String
ieBrowserAttachTimeout :: Integer
ieRequireWindowFocus :: Bool
ieEnableElementCacheCleanup :: Bool
ieEnablePersistentHover :: Bool
ieElementScrollBehavior :: IEElementScrollBehavior
ieInitialBrowserUrl :: Maybe Text
ieIgnoreZoomSetting :: Bool
ieIgnoreProtectedModeSettings :: Bool
..}
          -> [Key
"ignoreProtectedModeSettings" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
ieIgnoreProtectedModeSettings
             ,Key
"ignoreZoomSetting" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
ieIgnoreZoomSetting
             ,Key
"initialBrowserUrl" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Text
ieInitialBrowserUrl
             ,Key
"elementScrollBehavior" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= IEElementScrollBehavior
ieElementScrollBehavior
             ,Key
"enablePersistentHover" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
ieEnablePersistentHover
             ,Key
"enableElementCacheCleanup" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
ieEnableElementCacheCleanup
             ,Key
"requireWindowFocus" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
ieRequireWindowFocus
             ,Key
"browserAttachTimeout" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Integer
ieBrowserAttachTimeout
             ,Key
"logFile" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe String
ieLogFile
             ,Key
"logLevel" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= IELogLevel
ieLogLevel
             ,Key
"host" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Text
ieHost
             ,Key
"extractPath" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Text
ieExtractPath
             ,Key
"silent" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
ieSilent
             ,Key
"forceCreateProcess" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
ieForceCreateProcess
             ,Key
"internetExplorerSwitches" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Text
ieSwitches
             ]
        Opera{Bool
Maybe Int
Maybe String
Maybe Word16
LogLevel
operaLogPref :: Browser -> LogLevel
operaLogFile :: Browser -> Maybe String
operaOptions :: Browser -> Maybe String
operaHost :: Browser -> Maybe String
operaPort :: Browser -> Maybe Word16
operaLauncher :: Browser -> Maybe String
operaDisplay :: Browser -> Maybe Int
operaIdle :: Browser -> Bool
operaAutoStart :: Browser -> Bool
operaDetach :: Browser -> Bool
operaProduct :: Browser -> Maybe String
operaBinary :: Browser -> Maybe String
operaLogPref :: LogLevel
operaLogFile :: Maybe String
operaOptions :: Maybe String
operaHost :: Maybe String
operaPort :: Maybe Word16
operaLauncher :: Maybe String
operaDisplay :: Maybe Int
operaIdle :: Bool
operaAutoStart :: Bool
operaDetach :: Bool
operaProduct :: Maybe String
operaBinary :: Maybe String
..}
          -> forall a. [Maybe a] -> [a]
catMaybes [ forall {f :: * -> *} {b} {a}.
(Functor f, KeyValue b, ToJSON a) =>
Key -> f a -> f b
opt Key
"opera.binary" Maybe String
operaBinary
                       , forall {f :: * -> *} {b} {a}.
(Functor f, KeyValue b, ToJSON a) =>
Key -> f a -> f b
opt Key
"opera.display" Maybe Int
operaDisplay
                       , forall {f :: * -> *} {b} {a}.
(Functor f, KeyValue b, ToJSON a) =>
Key -> f a -> f b
opt Key
"opera.product" Maybe String
operaProduct
                       , forall {f :: * -> *} {b} {a}.
(Functor f, KeyValue b, ToJSON a) =>
Key -> f a -> f b
opt Key
"opera.launcher" Maybe String
operaLauncher
                       , forall {f :: * -> *} {b} {a}.
(Functor f, KeyValue b, ToJSON a) =>
Key -> f a -> f b
opt Key
"opera.host" Maybe String
operaHost
                       , forall {f :: * -> *} {b} {a}.
(Functor f, KeyValue b, ToJSON a) =>
Key -> f a -> f b
opt Key
"opera.logging.file" Maybe String
operaLogFile
                       ]
             forall a. [a] -> [a] -> [a]
++ [Key
"opera.detatch" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
operaDetach
                ,Key
"opera.no_quit" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
operaDetach --backwards compatability
                ,Key
"opera.autostart" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
operaAutoStart
                , Key
"opera.idle" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
operaIdle
                -- ,"opera.profile" .= operaProfile
                ,Key
"opera.port" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. a -> Maybe a -> a
fromMaybe forall a. Bounded a => a
maxBound {- (-1) -} Maybe Word16
operaPort
                 --note: consider replacing operaOptions with a list of options
                ,Key
"opera.arguments" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe String
operaOptions
                ,Key
"opera.logging.level" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= LogLevel
operaLogPref
                ]

        Phantomjs {[String]
Maybe String
phantomjsOptions :: Browser -> [String]
phantomjsBinary :: Browser -> Maybe String
phantomjsOptions :: [String]
phantomjsBinary :: Maybe String
..}
          -> forall a. [Maybe a] -> [a]
catMaybes [ forall {f :: * -> *} {b} {a}.
(Functor f, KeyValue b, ToJSON a) =>
Key -> f a -> f b
opt Key
"phantomjs.binary.path" Maybe String
phantomjsBinary
                       ] forall a. [a] -> [a] -> [a]
++
                       [ Key
"phantomjs.cli.args" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [String]
phantomjsOptions
                       ]

        Browser
_ -> []

        where
          opt :: Key -> f a -> f b
opt Key
k = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Key
k forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.=)


instance FromJSON Capabilities where
  parseJSON :: Value -> Parser Capabilities
parseJSON (Object Object
o) = do
    Browser
browser <- forall a. FromJSON a => Text -> Parser a
req Text
"browserName"
    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
Capabilities forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Browser -> Parser Browser
getBrowserCaps Browser
browser
                 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"version" forall a. Maybe a
Nothing
                 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> Parser a
req Text
"platform"
                 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"proxy" ProxyType
NoProxy
                 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"javascriptEnabled"
                 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"takesScreenshot"
                 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"handlesAlerts"
                 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"databaseEnabled"
                 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"locationContextEnabled"
                 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"applicationCacheEnabled"
                 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"browserConnectionEnabled"
                 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"cssSelectorEnabled"
                 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"webStorageEnabled"
                 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"rotatable"
                 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"acceptSslCerts"
                 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"nativeEvents"
                 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"unexpectedAlertBehaviour" forall a. Maybe a
Nothing
                 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure (Browser -> [Pair]
additionalCapabilities Browser
browser)

    where --some helpful JSON accessor shorthands
          req :: FromJSON a => Text -> Parser a
          req :: forall a. FromJSON a => Text -> Parser a
req = (Object
o forall a. FromJSON a => Object -> Key -> Parser a
.:) forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Key
fromText  -- required field
          opt :: FromJSON a => Text -> a -> Parser a
          opt :: forall a. FromJSON a => Text -> a -> Parser a
opt Text
k a
d = Object
o forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:?? Text
k forall a. Parser (Maybe a) -> a -> Parser a
.!= a
d -- optional field
          b :: Text -> Parser (Maybe Bool)
          b :: Text -> Parser (Maybe Bool)
b Text
k = forall a. FromJSON a => Text -> a -> Parser a
opt Text
k forall a. Maybe a
Nothing     -- Maybe Bool field

          -- produce additionalCaps by removing known capabilities from the JSON object
          additionalCapabilities :: Browser -> [Pair]
additionalCapabilities = forall v. KeyMap v -> [(Key, v)]
HM.toList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr forall v. Key -> KeyMap v -> KeyMap v
HM.delete Object
o forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {a}. IsString a => Browser -> [a]
knownCapabilities

          knownCapabilities :: Browser -> [a]
knownCapabilities Browser
browser =
            [ a
"browserName", a
"version", a
"platform", a
"proxy"
            , a
"javascriptEnabled", a
"takesScreenshot", a
"handlesAlerts"
            , a
"databaseEnabled", a
"locationContextEnabled"
            , a
"applicationCacheEnabled", a
"browserConnectionEnabled"
            , a
"cssSelectorEnabled",a
"webStorageEnabled", a
"rotatable"
            , a
"acceptSslCerts", a
"nativeEvents", a
"unexpectedBrowserBehaviour"]
            forall a. [a] -> [a] -> [a]
++ case Browser
browser of
              Firefox {} -> [a
"firefox_profile", a
"loggingPrefs", a
"firefox_binary", a
"acceptInsecureCerts"]
              Chrome {} -> [a
"chrome.chromedriverVersion", a
"chrome.extensions", a
"chrome.switches", a
"chrome.extensions"]
              IE {} -> [a
"ignoreProtectedModeSettings", a
"ignoreZoomSettings", a
"initialBrowserUrl", a
"elementScrollBehavior"
                       ,a
"enablePersistentHover", a
"enableElementCacheCleanup", a
"requireWindowFocus", a
"browserAttachTimeout"
                       ,a
"logFile", a
"logLevel", a
"host", a
"extractPath", a
"silent", a
"forceCreateProcess", a
"internetExplorerSwitches"]
              Opera {} -> [a
"opera.binary", a
"opera.product", a
"opera.no_quit", a
"opera.autostart", a
"opera.idle", a
"opera.display"
                          ,a
"opera.launcher", a
"opera.port", a
"opera.host", a
"opera.arguments", a
"opera.logging.file", a
"opera.logging.level"]
              Browser
_ -> []
          getBrowserCaps :: Browser -> Parser Browser
getBrowserCaps Browser
browser =
            case Browser
browser of
              Firefox {} -> Maybe (PreparedProfile Firefox)
-> LogLevel -> Maybe String -> Maybe Bool -> Browser
Firefox forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"firefox_profile" forall a. Maybe a
Nothing
                                    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"loggingPrefs" forall a. Default a => a
def
                                    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"firefox_binary" forall a. Maybe a
Nothing
                                    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"acceptInsecureCerts" forall a. Maybe a
Nothing
              Chrome {} -> Maybe String
-> Maybe String
-> [String]
-> [ChromeExtension]
-> Object
-> Browser
Chrome forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"chrome.chromedriverVersion" forall a. Maybe a
Nothing
                                  forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"chrome.binary" forall a. Maybe a
Nothing
                                  forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"chrome.switches" []
                                  forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"chrome.extensions" []
                                  forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall v. KeyMap v
HM.empty
              IE {} -> Bool
-> Bool
-> Maybe Text
-> IEElementScrollBehavior
-> Bool
-> Bool
-> Bool
-> Integer
-> Maybe String
-> IELogLevel
-> Maybe Text
-> Maybe Text
-> Bool
-> Bool
-> Maybe Text
-> Browser
IE forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"ignoreProtectedModeSettings" Bool
True
                          forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"ignoreZoomSettings" Bool
False
                          forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"initialBrowserUrl" forall a. Maybe a
Nothing
                          forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"elementScrollBehavior" forall a. Default a => a
def
                          forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"enablePersistentHover" Bool
True
                          forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"enableElementCacheCleanup" Bool
True
                          forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"requireWindowFocus" Bool
False
                          forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"browserAttachTimeout" Integer
0
                          forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"logFile" forall a. Maybe a
Nothing
                          forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"logLevel" forall a. Default a => a
def
                          forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"host" forall a. Maybe a
Nothing
                          forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"extractPath" forall a. Maybe a
Nothing
                          forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"silent" Bool
False
                          forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"forceCreateProcess" Bool
False
                          forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"internetExplorerSwitches" forall a. Maybe a
Nothing
              Opera {} -> Maybe String
-> Maybe String
-> Bool
-> Bool
-> Bool
-> Maybe Int
-> Maybe String
-> Maybe Word16
-> Maybe String
-> Maybe String
-> Maybe String
-> LogLevel
-> Browser
Opera forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.binary" forall a. Maybe a
Nothing
                                forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.product" forall a. Maybe a
Nothing
                                forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.no_quit" Bool
False
                                forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.autostart" Bool
True
                                forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.idle" Bool
False
                                forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.display" forall a. Maybe a
Nothing
                                forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.launcher" forall a. Maybe a
Nothing
                                forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.port" (forall a. a -> Maybe a
Just Word16
0)
                                forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.host" forall a. Maybe a
Nothing
                                forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.arguments" forall a. Maybe a
Nothing
                                forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.logging.file" forall a. Maybe a
Nothing
                                forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.logging.level" forall a. Default a => a
def
              Browser
_ -> forall (m :: * -> *) a. Monad m => a -> m a
return Browser
browser

  parseJSON Value
v = forall a. String -> Value -> Parser a
typeMismatch String
"Capabilities" Value
v

-- |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 { -- |The firefox profile to use. If Nothing,
                         -- a default temporary profile is automatically created
                         -- and used.
                         Browser -> Maybe (PreparedProfile Firefox)
ffProfile :: Maybe (PreparedProfile Firefox)
                         -- |Firefox logging preference
                       , Browser -> LogLevel
ffLogPref :: LogLevel
                         -- |Server-side path to Firefox binary. If Nothing,
                         -- use a sensible system-based default.
                       , Browser -> Maybe String
ffBinary :: Maybe FilePath
                         -- |Available after Firefox 52, and required only for Firefox
                         -- geckodriver. Indicates whether untrusted and self-signed TLS
                         -- certificates are implicitly trusted on navigation for the
                         -- duration of the session.
                       , Browser -> Maybe Bool
ffAcceptInsecureCerts :: Maybe Bool
                       }
             | Chrome { -- |Version of the Chrome Webdriver server server to use
                        --
                        -- for more information on chromedriver see
                        -- <https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver>
                        Browser -> Maybe String
chromeDriverVersion :: Maybe String
                        -- |Server-side path to Chrome binary. If Nothing,
                        -- use a sensible system-based default.
                      , Browser -> Maybe String
chromeBinary :: Maybe FilePath
                        -- |A list of command-line options to pass to the
                        -- Chrome binary.
                      , Browser -> [String]
chromeOptions :: [String]
                        -- |A list of extensions to use.
                      , Browser -> [ChromeExtension]
chromeExtensions :: [ChromeExtension]
                        -- | Experimental options not yet exposed through a standard API.
                      , Browser -> Object
chromeExperimentalOptions :: Object
                      }
             | IE { -- |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.
                    Browser -> Bool
ieIgnoreProtectedModeSettings :: Bool
                    -- |Indicates whether to skip the check that the browser's zoom
                    -- level is set to 100%. Value is set to false by default.
                  , Browser -> Bool
ieIgnoreZoomSetting :: 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.
                  , Browser -> Maybe Text
ieInitialBrowserUrl :: 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.
                  , Browser -> IEElementScrollBehavior
ieElementScrollBehavior :: 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.
                  , Browser -> Bool
ieEnablePersistentHover :: 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.
                  , Browser -> Bool
ieEnableElementCacheCleanup :: 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.
                  , Browser -> Bool
ieRequireWindowFocus :: 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.
                  , Browser -> Integer
ieBrowserAttachTimeout :: Integer
                    -- |The path to file where server should write log messages to.
                    -- By default it writes to stdout.
                  , Browser -> Maybe String
ieLogFile :: Maybe FilePath
                    -- |The log level used by the server. Defaults to 'IELogFatal'
                  , Browser -> IELogLevel
ieLogLevel :: IELogLevel
                    -- |The address of the host adapter on which the server will listen
                    -- for commands.
                  , Browser -> Maybe Text
ieHost :: Maybe Text
                    -- |The path to the directory used to extract supporting files used
                    -- by the server. Defaults to the TEMP directory if not specified.
                  , Browser -> Maybe Text
ieExtractPath :: Maybe Text
                    -- |Suppresses diagnostic output when the server is started.
                  , Browser -> Bool
ieSilent :: 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.
                  , Browser -> Bool
ieForceCreateProcess :: Bool
                    -- |Specifies command-line switches with which to launch Internet
                    -- Explorer. This is only valid when used with the
                    -- forceCreateProcess.
                  , Browser -> Maybe Text
ieSwitches :: Maybe Text
                  }
             | Opera { -- |Server-side path to the Opera binary
                       Browser -> Maybe String
operaBinary    :: Maybe FilePath
                     --, operaNoRestart :: Maybe Bool
                       -- |Which Opera product we're using, e.g. \"desktop\",
                       -- \"core\"
                     , Browser -> Maybe String
operaProduct   :: Maybe String
                       -- |Whether the Opera instance should stay open after
                       -- we close the session. If false, closing the session
                       -- closes the browser.
                     , Browser -> Bool
operaDetach    :: Bool
                       -- |Whether to auto-start the Opera binary. If false,
                       -- OperaDriver will wait for a connection from the
                       -- browser. By default this is True.
                     , Browser -> Bool
operaAutoStart :: 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.
                     , Browser -> Bool
operaIdle      :: Bool
                       -- |(*nix only) which X display to use.
                     , Browser -> Maybe Int
operaDisplay   :: Maybe Int
                     --, operaProfile   :: Maybe (PreparedProfile Opera)
                       -- |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.
                     , Browser -> Maybe String
operaLauncher  :: 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.
                     , Browser -> Maybe Word16
operaPort      :: Maybe Word16
                       -- |The host Opera should connect to. Unless you're
                       -- starting Opera manually you won't need this.
                     , Browser -> Maybe String
operaHost      :: Maybe String
                       -- |Command-line arguments to pass to Opera.
                     , Browser -> Maybe String
operaOptions   :: Maybe String
                       -- |Where to send the log output. If Nothing, logging is
                       -- disabled.
                     , Browser -> Maybe String
operaLogFile   :: Maybe FilePath
                       -- |Log level preference. Defaults to 'LogInfo'
                     , Browser -> LogLevel
operaLogPref   :: LogLevel
                     }

             | Phantomjs { Browser -> Maybe String
phantomjsBinary  :: Maybe FilePath
                         , Browser -> [String]
phantomjsOptions :: [String]
                         }

             | HTMLUnit
             | IPhone
             | IPad
             | Android
             -- |some other browser, specified by a string name
             | Browser Text
             deriving (Browser -> Browser -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Browser -> Browser -> Bool
$c/= :: Browser -> Browser -> Bool
== :: Browser -> Browser -> Bool
$c== :: Browser -> Browser -> Bool
Eq, Int -> Browser -> ShowS
[Browser] -> ShowS
Browser -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Browser] -> ShowS
$cshowList :: [Browser] -> ShowS
show :: Browser -> String
$cshow :: Browser -> String
showsPrec :: Int -> Browser -> ShowS
$cshowsPrec :: Int -> Browser -> ShowS
Show)

instance Default Browser where
  def :: Browser
def = Browser
firefox


instance ToJSON Browser where
  toJSON :: Browser -> Value
toJSON Firefox {}   = Text -> Value
String Text
"firefox"
  toJSON Chrome {}    = Text -> Value
String Text
"chrome"
  toJSON Opera {}     = Text -> Value
String Text
"opera"
  toJSON IE {}        = Text -> Value
String Text
"internet explorer"
  toJSON Phantomjs {} = Text -> Value
String Text
"phantomjs"
  toJSON (Browser Text
b)  = Text -> Value
String Text
b
  toJSON Browser
b            = Text -> Value
String forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
toLower forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IsString a => String -> a
fromString forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> String
show forall a b. (a -> b) -> a -> b
$ Browser
b

instance FromJSON Browser where
  parseJSON :: Value -> Parser Browser
parseJSON (String Text
jStr) = case Text -> Text
toLower Text
jStr of
    Text
"firefox"           -> forall (m :: * -> *) a. Monad m => a -> m a
return Browser
firefox
    Text
"chrome"            -> forall (m :: * -> *) a. Monad m => a -> m a
return Browser
chrome
    Text
"internet explorer" -> forall (m :: * -> *) a. Monad m => a -> m a
return Browser
ie
    Text
"opera"             -> forall (m :: * -> *) a. Monad m => a -> m a
return Browser
opera
    Text
"phantomjs"         -> forall (m :: * -> *) a. Monad m => a -> m a
return Browser
phantomjs
    -- "safari"            -> return safari
    Text
"iphone"            -> forall (m :: * -> *) a. Monad m => a -> m a
return Browser
iPhone
    Text
"ipad"              -> forall (m :: * -> *) a. Monad m => a -> m a
return Browser
iPad
    Text
"android"           -> forall (m :: * -> *) a. Monad m => a -> m a
return Browser
android
    Text
"htmlunit"          -> forall (m :: * -> *) a. Monad m => a -> m a
return Browser
htmlUnit
    Text
other               -> forall (m :: * -> *) a. Monad m => a -> m a
return (Text -> Browser
Browser Text
other)
  parseJSON Value
v = forall a. String -> Value -> Parser a
typeMismatch String
"Browser" Value
v


-- |Default Firefox settings. All Maybe fields are set to Nothing. ffLogPref
-- is set to 'LogInfo'.
firefox :: Browser
firefox :: Browser
firefox = Maybe (PreparedProfile Firefox)
-> LogLevel -> Maybe String -> Maybe Bool -> Browser
Firefox forall a. Maybe a
Nothing forall a. Default a => a
def forall a. Maybe a
Nothing forall a. Maybe a
Nothing

-- |Default Chrome settings. All Maybe fields are set to Nothing, no options are
-- specified, and no extensions are used.
chrome :: Browser
chrome :: Browser
chrome = Maybe String
-> Maybe String
-> [String]
-> [ChromeExtension]
-> Object
-> Browser
Chrome forall a. Maybe a
Nothing forall a. Maybe a
Nothing [] [] forall v. KeyMap v
HM.empty

-- |Default IE settings. See the 'IE' constructor for more details on
-- individual defaults
ie :: Browser
ie :: Browser
ie = IE { ieIgnoreProtectedModeSettings :: Bool
ieIgnoreProtectedModeSettings = Bool
True
        , ieIgnoreZoomSetting :: Bool
ieIgnoreZoomSetting = Bool
False
        , ieInitialBrowserUrl :: Maybe Text
ieInitialBrowserUrl = forall a. Maybe a
Nothing
        , ieElementScrollBehavior :: IEElementScrollBehavior
ieElementScrollBehavior = forall a. Default a => a
def
        , ieEnablePersistentHover :: Bool
ieEnablePersistentHover = Bool
True
        , ieEnableElementCacheCleanup :: Bool
ieEnableElementCacheCleanup = Bool
True
        , ieRequireWindowFocus :: Bool
ieRequireWindowFocus = Bool
False
        , ieBrowserAttachTimeout :: Integer
ieBrowserAttachTimeout = Integer
0
        , ieLogFile :: Maybe String
ieLogFile = forall a. Maybe a
Nothing
        , ieLogLevel :: IELogLevel
ieLogLevel = forall a. Default a => a
def
        , ieHost :: Maybe Text
ieHost = forall a. Maybe a
Nothing
        , ieExtractPath :: Maybe Text
ieExtractPath = forall a. Maybe a
Nothing
        , ieSilent :: Bool
ieSilent = Bool
False
        , ieForceCreateProcess :: Bool
ieForceCreateProcess = Bool
False
        , ieSwitches :: Maybe Text
ieSwitches = forall a. Maybe a
Nothing
        }

-- |Default Opera settings. See the 'Opera' constructor for more details on
-- individual defaults.
opera :: Browser
opera :: Browser
opera = Opera { operaBinary :: Maybe String
operaBinary = forall a. Maybe a
Nothing
              --, operaNoRestart = Nothing
              , operaProduct :: Maybe String
operaProduct = forall a. Maybe a
Nothing
              , operaDetach :: Bool
operaDetach = Bool
False
              , operaAutoStart :: Bool
operaAutoStart = Bool
True
              , operaDisplay :: Maybe Int
operaDisplay = forall a. Maybe a
Nothing
              , operaIdle :: Bool
operaIdle = Bool
False
--              , operaProfile = Nothing
              , operaLauncher :: Maybe String
operaLauncher = forall a. Maybe a
Nothing
              , operaHost :: Maybe String
operaHost = forall a. Maybe a
Nothing
              , operaPort :: Maybe Word16
operaPort = forall a. a -> Maybe a
Just Word16
0
              , operaOptions :: Maybe String
operaOptions = forall a. Maybe a
Nothing
              , operaLogFile :: Maybe String
operaLogFile = forall a. Maybe a
Nothing
              , operaLogPref :: LogLevel
operaLogPref = forall a. Default a => a
def
              }

phantomjs :: Browser
phantomjs :: Browser
phantomjs = Maybe String -> [String] -> Browser
Phantomjs forall a. Maybe a
Nothing []

--safari :: Browser
--safari = Safari

htmlUnit :: Browser
htmlUnit :: Browser
htmlUnit = Browser
HTMLUnit

iPhone :: Browser
iPhone :: Browser
iPhone = Browser
IPhone

iPad :: Browser
iPad :: Browser
iPad = Browser
IPad

android :: Browser
android :: Browser
android = Browser
Android

-- |Represents platform options supported by WebDriver. The value Any represents
-- no preference.
data Platform = Windows | XP | Vista | Mac | Linux | Unix | Any
              deriving (Platform -> Platform -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Platform -> Platform -> Bool
$c/= :: Platform -> Platform -> Bool
== :: Platform -> Platform -> Bool
$c== :: Platform -> Platform -> Bool
Eq, Int -> Platform -> ShowS
[Platform] -> ShowS
Platform -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Platform] -> ShowS
$cshowList :: [Platform] -> ShowS
show :: Platform -> String
$cshow :: Platform -> String
showsPrec :: Int -> Platform -> ShowS
$cshowsPrec :: Int -> Platform -> ShowS
Show, Eq Platform
Platform -> Platform -> Bool
Platform -> Platform -> Ordering
Platform -> Platform -> Platform
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Platform -> Platform -> Platform
$cmin :: Platform -> Platform -> Platform
max :: Platform -> Platform -> Platform
$cmax :: Platform -> Platform -> Platform
>= :: Platform -> Platform -> Bool
$c>= :: Platform -> Platform -> Bool
> :: Platform -> Platform -> Bool
$c> :: Platform -> Platform -> Bool
<= :: Platform -> Platform -> Bool
$c<= :: Platform -> Platform -> Bool
< :: Platform -> Platform -> Bool
$c< :: Platform -> Platform -> Bool
compare :: Platform -> Platform -> Ordering
$ccompare :: Platform -> Platform -> Ordering
Ord, Platform
forall a. a -> a -> Bounded a
maxBound :: Platform
$cmaxBound :: Platform
minBound :: Platform
$cminBound :: Platform
Bounded, Int -> Platform
Platform -> Int
Platform -> [Platform]
Platform -> Platform
Platform -> Platform -> [Platform]
Platform -> Platform -> Platform -> [Platform]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Platform -> Platform -> Platform -> [Platform]
$cenumFromThenTo :: Platform -> Platform -> Platform -> [Platform]
enumFromTo :: Platform -> Platform -> [Platform]
$cenumFromTo :: Platform -> Platform -> [Platform]
enumFromThen :: Platform -> Platform -> [Platform]
$cenumFromThen :: Platform -> Platform -> [Platform]
enumFrom :: Platform -> [Platform]
$cenumFrom :: Platform -> [Platform]
fromEnum :: Platform -> Int
$cfromEnum :: Platform -> Int
toEnum :: Int -> Platform
$ctoEnum :: Int -> Platform
pred :: Platform -> Platform
$cpred :: Platform -> Platform
succ :: Platform -> Platform
$csucc :: Platform -> Platform
Enum)

instance ToJSON Platform where
  toJSON :: Platform -> Value
toJSON = Text -> Value
String forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
toUpper forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IsString a => String -> a
fromString forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> String
show

instance FromJSON Platform where
  parseJSON :: Value -> Parser Platform
parseJSON (String Text
jStr) = case Text -> Text
toLower Text
jStr of
    Text
"windows" -> forall (m :: * -> *) a. Monad m => a -> m a
return Platform
Windows
    Text
"xp"      -> forall (m :: * -> *) a. Monad m => a -> m a
return Platform
XP
    Text
"vista"   -> forall (m :: * -> *) a. Monad m => a -> m a
return Platform
Vista
    Text
"mac"     -> forall (m :: * -> *) a. Monad m => a -> m a
return Platform
Mac
    Text
"linux"   -> forall (m :: * -> *) a. Monad m => a -> m a
return Platform
Linux
    Text
"unix"    -> forall (m :: * -> *) a. Monad m => a -> m a
return Platform
Unix
    Text
"any"     -> forall (m :: * -> *) a. Monad m => a -> m a
return Platform
Any
    Text
err -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ String
"Invalid Platform string " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Text
err
  parseJSON Value
v = forall a. String -> Value -> Parser a
typeMismatch String
"Platform" Value
v

-- |Available settings for the proxy 'Capabilities' field
data ProxyType = NoProxy
               | UseSystemSettings
               | AutoDetect
                 -- |Use a proxy auto-config file specified by URL
               | PAC { ProxyType -> String
autoConfigUrl :: String }
                 -- |Manually specify proxy hosts as hostname:port strings.
                 -- Note that behavior is undefined for empty strings.
               | Manual { ProxyType -> String
ftpProxy  :: String
                        , ProxyType -> String
sslProxy  :: String
                        , ProxyType -> String
httpProxy :: String
                        }
               deriving (ProxyType -> ProxyType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProxyType -> ProxyType -> Bool
$c/= :: ProxyType -> ProxyType -> Bool
== :: ProxyType -> ProxyType -> Bool
$c== :: ProxyType -> ProxyType -> Bool
Eq, Int -> ProxyType -> ShowS
[ProxyType] -> ShowS
ProxyType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProxyType] -> ShowS
$cshowList :: [ProxyType] -> ShowS
show :: ProxyType -> String
$cshow :: ProxyType -> String
showsPrec :: Int -> ProxyType -> ShowS
$cshowsPrec :: Int -> ProxyType -> ShowS
Show)

instance FromJSON ProxyType where
  parseJSON :: Value -> Parser ProxyType
parseJSON (Object Object
obj) = do
    Text
pTyp <- forall a. FromJSON a => Text -> Parser a
f Text
"proxyType"
    case Text -> Text
toLower Text
pTyp of
      Text
"direct" -> forall (m :: * -> *) a. Monad m => a -> m a
return ProxyType
NoProxy
      Text
"system" -> forall (m :: * -> *) a. Monad m => a -> m a
return ProxyType
UseSystemSettings
      Text
"pac"    -> String -> ProxyType
PAC forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. FromJSON a => Text -> Parser a
f Text
"autoConfigUrl"
      Text
"manual" -> String -> String -> String -> ProxyType
Manual forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. FromJSON a => Text -> Parser a
f Text
"ftpProxy"
                         forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> Parser a
f Text
"sslProxy"
                         forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. FromJSON a => Text -> Parser a
f Text
"httpProxy"
      Text
_ -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ String
"Invalid ProxyType " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Text
pTyp
    where
      f :: FromJSON a => Text -> Parser a
      f :: forall a. FromJSON a => Text -> Parser a
f = (Object
obj forall a. FromJSON a => Object -> Key -> Parser a
.:) forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Key
fromText
  parseJSON Value
v = forall a. String -> Value -> Parser a
typeMismatch String
"ProxyType" Value
v

instance ToJSON ProxyType where
  toJSON :: ProxyType -> Value
toJSON ProxyType
pt = [Pair] -> Value
object forall a b. (a -> b) -> a -> b
$ case ProxyType
pt of
    ProxyType
NoProxy ->
      [Key
"proxyType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (String
"DIRECT" :: String)]
    ProxyType
UseSystemSettings ->
      [Key
"proxyType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (String
"SYSTEM" :: String)]
    ProxyType
AutoDetect ->
      [Key
"proxyType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (String
"AUTODETECT" :: String)]
    PAC{autoConfigUrl :: ProxyType -> String
autoConfigUrl = String
url} ->
      [Key
"proxyType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (String
"PAC" :: String)
      ,Key
"proxyAutoconfigUrl" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= String
url
      ]
    Manual{ftpProxy :: ProxyType -> String
ftpProxy = String
ftp, sslProxy :: ProxyType -> String
sslProxy = String
ssl, httpProxy :: ProxyType -> String
httpProxy = String
http} ->
      [Key
"proxyType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (String
"MANUAL" :: String)
      ,Key
"ftpProxy"  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= String
ftp
      ,Key
"sslProxy"  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= String
ssl
      ,Key
"httpProxy" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= String
http
      ]

data UnexpectedAlertBehavior = AcceptAlert | DismissAlert | IgnoreAlert
                              deriving (UnexpectedAlertBehavior
forall a. a -> a -> Bounded a
maxBound :: UnexpectedAlertBehavior
$cmaxBound :: UnexpectedAlertBehavior
minBound :: UnexpectedAlertBehavior
$cminBound :: UnexpectedAlertBehavior
Bounded, Int -> UnexpectedAlertBehavior
UnexpectedAlertBehavior -> Int
UnexpectedAlertBehavior -> [UnexpectedAlertBehavior]
UnexpectedAlertBehavior -> UnexpectedAlertBehavior
UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> [UnexpectedAlertBehavior]
UnexpectedAlertBehavior
-> UnexpectedAlertBehavior
-> UnexpectedAlertBehavior
-> [UnexpectedAlertBehavior]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior
-> UnexpectedAlertBehavior
-> [UnexpectedAlertBehavior]
$cenumFromThenTo :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior
-> UnexpectedAlertBehavior
-> [UnexpectedAlertBehavior]
enumFromTo :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> [UnexpectedAlertBehavior]
$cenumFromTo :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> [UnexpectedAlertBehavior]
enumFromThen :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> [UnexpectedAlertBehavior]
$cenumFromThen :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> [UnexpectedAlertBehavior]
enumFrom :: UnexpectedAlertBehavior -> [UnexpectedAlertBehavior]
$cenumFrom :: UnexpectedAlertBehavior -> [UnexpectedAlertBehavior]
fromEnum :: UnexpectedAlertBehavior -> Int
$cfromEnum :: UnexpectedAlertBehavior -> Int
toEnum :: Int -> UnexpectedAlertBehavior
$ctoEnum :: Int -> UnexpectedAlertBehavior
pred :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior
$cpred :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior
succ :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior
$csucc :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior
Enum, UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
$c/= :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
== :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
$c== :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
Eq, Eq UnexpectedAlertBehavior
UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Ordering
UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> UnexpectedAlertBehavior
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> UnexpectedAlertBehavior
$cmin :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> UnexpectedAlertBehavior
max :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> UnexpectedAlertBehavior
$cmax :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> UnexpectedAlertBehavior
>= :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
$c>= :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
> :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
$c> :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
<= :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
$c<= :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
< :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
$c< :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
compare :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Ordering
$ccompare :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Ordering
Ord, ReadPrec [UnexpectedAlertBehavior]
ReadPrec UnexpectedAlertBehavior
Int -> ReadS UnexpectedAlertBehavior
ReadS [UnexpectedAlertBehavior]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UnexpectedAlertBehavior]
$creadListPrec :: ReadPrec [UnexpectedAlertBehavior]
readPrec :: ReadPrec UnexpectedAlertBehavior
$creadPrec :: ReadPrec UnexpectedAlertBehavior
readList :: ReadS [UnexpectedAlertBehavior]
$creadList :: ReadS [UnexpectedAlertBehavior]
readsPrec :: Int -> ReadS UnexpectedAlertBehavior
$creadsPrec :: Int -> ReadS UnexpectedAlertBehavior
Read, Int -> UnexpectedAlertBehavior -> ShowS
[UnexpectedAlertBehavior] -> ShowS
UnexpectedAlertBehavior -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UnexpectedAlertBehavior] -> ShowS
$cshowList :: [UnexpectedAlertBehavior] -> ShowS
show :: UnexpectedAlertBehavior -> String
$cshow :: UnexpectedAlertBehavior -> String
showsPrec :: Int -> UnexpectedAlertBehavior -> ShowS
$cshowsPrec :: Int -> UnexpectedAlertBehavior -> ShowS
Show)

instance ToJSON UnexpectedAlertBehavior where
  toJSON :: UnexpectedAlertBehavior -> Value
toJSON UnexpectedAlertBehavior
AcceptAlert  = Text -> Value
String Text
"accept"
  toJSON UnexpectedAlertBehavior
DismissAlert = Text -> Value
String Text
"dismiss"
  toJSON UnexpectedAlertBehavior
IgnoreAlert  = Text -> Value
String Text
"ignore"

instance FromJSON UnexpectedAlertBehavior where
  parseJSON :: Value -> Parser UnexpectedAlertBehavior
parseJSON (String Text
s) =
    forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ case Text
s of
      Text
"accept"  -> UnexpectedAlertBehavior
AcceptAlert
      Text
"dismiss" -> UnexpectedAlertBehavior
DismissAlert
      Text
"ignore"  -> UnexpectedAlertBehavior
IgnoreAlert
      Text
err       -> forall a e. Exception e => e -> a
throw forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> BadJSON
BadJSON
                   forall a b. (a -> b) -> a -> b
$ String
"Invalid string value for UnexpectedAlertBehavior: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Text
err
  parseJSON Value
v = forall a. String -> Value -> Parser a
typeMismatch String
"UnexpectedAlertBehavior" Value
v

-- |Indicates a log verbosity level. Used in 'Firefox' and 'Opera' configuration.
data LogLevel = LogOff | LogSevere | LogWarning | LogInfo | LogConfig
              | LogFine | LogFiner | LogFinest | LogDebug | LogAll
             deriving (LogLevel -> LogLevel -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LogLevel -> LogLevel -> Bool
$c/= :: LogLevel -> LogLevel -> Bool
== :: LogLevel -> LogLevel -> Bool
$c== :: LogLevel -> LogLevel -> Bool
Eq, Int -> LogLevel -> ShowS
[LogLevel] -> ShowS
LogLevel -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LogLevel] -> ShowS
$cshowList :: [LogLevel] -> ShowS
show :: LogLevel -> String
$cshow :: LogLevel -> String
showsPrec :: Int -> LogLevel -> ShowS
$cshowsPrec :: Int -> LogLevel -> ShowS
Show, ReadPrec [LogLevel]
ReadPrec LogLevel
Int -> ReadS LogLevel
ReadS [LogLevel]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LogLevel]
$creadListPrec :: ReadPrec [LogLevel]
readPrec :: ReadPrec LogLevel
$creadPrec :: ReadPrec LogLevel
readList :: ReadS [LogLevel]
$creadList :: ReadS [LogLevel]
readsPrec :: Int -> ReadS LogLevel
$creadsPrec :: Int -> ReadS LogLevel
Read, Eq LogLevel
LogLevel -> LogLevel -> Bool
LogLevel -> LogLevel -> Ordering
LogLevel -> LogLevel -> LogLevel
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: LogLevel -> LogLevel -> LogLevel
$cmin :: LogLevel -> LogLevel -> LogLevel
max :: LogLevel -> LogLevel -> LogLevel
$cmax :: LogLevel -> LogLevel -> LogLevel
>= :: LogLevel -> LogLevel -> Bool
$c>= :: LogLevel -> LogLevel -> Bool
> :: LogLevel -> LogLevel -> Bool
$c> :: LogLevel -> LogLevel -> Bool
<= :: LogLevel -> LogLevel -> Bool
$c<= :: LogLevel -> LogLevel -> Bool
< :: LogLevel -> LogLevel -> Bool
$c< :: LogLevel -> LogLevel -> Bool
compare :: LogLevel -> LogLevel -> Ordering
$ccompare :: LogLevel -> LogLevel -> Ordering
Ord, LogLevel
forall a. a -> a -> Bounded a
maxBound :: LogLevel
$cmaxBound :: LogLevel
minBound :: LogLevel
$cminBound :: LogLevel
Bounded, Int -> LogLevel
LogLevel -> Int
LogLevel -> [LogLevel]
LogLevel -> LogLevel
LogLevel -> LogLevel -> [LogLevel]
LogLevel -> LogLevel -> LogLevel -> [LogLevel]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: LogLevel -> LogLevel -> LogLevel -> [LogLevel]
$cenumFromThenTo :: LogLevel -> LogLevel -> LogLevel -> [LogLevel]
enumFromTo :: LogLevel -> LogLevel -> [LogLevel]
$cenumFromTo :: LogLevel -> LogLevel -> [LogLevel]
enumFromThen :: LogLevel -> LogLevel -> [LogLevel]
$cenumFromThen :: LogLevel -> LogLevel -> [LogLevel]
enumFrom :: LogLevel -> [LogLevel]
$cenumFrom :: LogLevel -> [LogLevel]
fromEnum :: LogLevel -> Int
$cfromEnum :: LogLevel -> Int
toEnum :: Int -> LogLevel
$ctoEnum :: Int -> LogLevel
pred :: LogLevel -> LogLevel
$cpred :: LogLevel -> LogLevel
succ :: LogLevel -> LogLevel
$csucc :: LogLevel -> LogLevel
Enum)

instance Default LogLevel where
  def :: LogLevel
def = LogLevel
LogInfo

instance ToJSON LogLevel where
  toJSON :: LogLevel -> Value
toJSON LogLevel
p= Text -> Value
String forall a b. (a -> b) -> a -> b
$ case LogLevel
p of
    LogLevel
LogOff -> Text
"OFF"
    LogLevel
LogSevere -> Text
"SEVERE"
    LogLevel
LogWarning -> Text
"WARNING"
    LogLevel
LogInfo -> Text
"INFO"
    LogLevel
LogConfig -> Text
"CONFIG"
    LogLevel
LogFine -> Text
"FINE"
    LogLevel
LogFiner -> Text
"FINER"
    LogLevel
LogFinest -> Text
"FINEST"
    LogLevel
LogDebug -> Text
"DEBUG"
    LogLevel
LogAll -> Text
"ALL"

instance FromJSON LogLevel where
  parseJSON :: Value -> Parser LogLevel
parseJSON (String Text
s) = forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ case Text
s of
    Text
"OFF" -> LogLevel
LogOff
    Text
"SEVERE" -> LogLevel
LogSevere
    Text
"WARNING" -> LogLevel
LogWarning
    Text
"INFO" -> LogLevel
LogInfo
    Text
"CONFIG" -> LogLevel
LogConfig
    Text
"FINE" -> LogLevel
LogFine
    Text
"FINER" -> LogLevel
LogFiner
    Text
"FINEST" -> LogLevel
LogFinest
    Text
"DEBUG" -> LogLevel
LogDebug
    Text
"ALL" -> LogLevel
LogAll
    Text
_ -> forall a e. Exception e => e -> a
throw forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> BadJSON
BadJSON forall a b. (a -> b) -> a -> b
$ String
"Invalid logging preference: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Text
s
  parseJSON Value
other = forall a. String -> Value -> Parser a
typeMismatch String
"LogLevel" Value
other


-- |Logging levels for Internet Explorer
data IELogLevel = IELogTrace | IELogDebug | IELogInfo | IELogWarn | IELogError
                | IELogFatal
                deriving (IELogLevel -> IELogLevel -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IELogLevel -> IELogLevel -> Bool
$c/= :: IELogLevel -> IELogLevel -> Bool
== :: IELogLevel -> IELogLevel -> Bool
$c== :: IELogLevel -> IELogLevel -> Bool
Eq, Int -> IELogLevel -> ShowS
[IELogLevel] -> ShowS
IELogLevel -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IELogLevel] -> ShowS
$cshowList :: [IELogLevel] -> ShowS
show :: IELogLevel -> String
$cshow :: IELogLevel -> String
showsPrec :: Int -> IELogLevel -> ShowS
$cshowsPrec :: Int -> IELogLevel -> ShowS
Show, ReadPrec [IELogLevel]
ReadPrec IELogLevel
Int -> ReadS IELogLevel
ReadS [IELogLevel]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IELogLevel]
$creadListPrec :: ReadPrec [IELogLevel]
readPrec :: ReadPrec IELogLevel
$creadPrec :: ReadPrec IELogLevel
readList :: ReadS [IELogLevel]
$creadList :: ReadS [IELogLevel]
readsPrec :: Int -> ReadS IELogLevel
$creadsPrec :: Int -> ReadS IELogLevel
Read, Eq IELogLevel
IELogLevel -> IELogLevel -> Bool
IELogLevel -> IELogLevel -> Ordering
IELogLevel -> IELogLevel -> IELogLevel
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: IELogLevel -> IELogLevel -> IELogLevel
$cmin :: IELogLevel -> IELogLevel -> IELogLevel
max :: IELogLevel -> IELogLevel -> IELogLevel
$cmax :: IELogLevel -> IELogLevel -> IELogLevel
>= :: IELogLevel -> IELogLevel -> Bool
$c>= :: IELogLevel -> IELogLevel -> Bool
> :: IELogLevel -> IELogLevel -> Bool
$c> :: IELogLevel -> IELogLevel -> Bool
<= :: IELogLevel -> IELogLevel -> Bool
$c<= :: IELogLevel -> IELogLevel -> Bool
< :: IELogLevel -> IELogLevel -> Bool
$c< :: IELogLevel -> IELogLevel -> Bool
compare :: IELogLevel -> IELogLevel -> Ordering
$ccompare :: IELogLevel -> IELogLevel -> Ordering
Ord, IELogLevel
forall a. a -> a -> Bounded a
maxBound :: IELogLevel
$cmaxBound :: IELogLevel
minBound :: IELogLevel
$cminBound :: IELogLevel
Bounded, Int -> IELogLevel
IELogLevel -> Int
IELogLevel -> [IELogLevel]
IELogLevel -> IELogLevel
IELogLevel -> IELogLevel -> [IELogLevel]
IELogLevel -> IELogLevel -> IELogLevel -> [IELogLevel]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: IELogLevel -> IELogLevel -> IELogLevel -> [IELogLevel]
$cenumFromThenTo :: IELogLevel -> IELogLevel -> IELogLevel -> [IELogLevel]
enumFromTo :: IELogLevel -> IELogLevel -> [IELogLevel]
$cenumFromTo :: IELogLevel -> IELogLevel -> [IELogLevel]
enumFromThen :: IELogLevel -> IELogLevel -> [IELogLevel]
$cenumFromThen :: IELogLevel -> IELogLevel -> [IELogLevel]
enumFrom :: IELogLevel -> [IELogLevel]
$cenumFrom :: IELogLevel -> [IELogLevel]
fromEnum :: IELogLevel -> Int
$cfromEnum :: IELogLevel -> Int
toEnum :: Int -> IELogLevel
$ctoEnum :: Int -> IELogLevel
pred :: IELogLevel -> IELogLevel
$cpred :: IELogLevel -> IELogLevel
succ :: IELogLevel -> IELogLevel
$csucc :: IELogLevel -> IELogLevel
Enum)

instance Default IELogLevel where
  def :: IELogLevel
def = IELogLevel
IELogFatal


instance ToJSON IELogLevel where
  toJSON :: IELogLevel -> Value
toJSON IELogLevel
p= Text -> Value
String forall a b. (a -> b) -> a -> b
$ case IELogLevel
p of
    IELogLevel
IELogTrace -> Text
"TRACE"
    IELogLevel
IELogDebug -> Text
"DEBUG"
    IELogLevel
IELogInfo -> Text
"INFO"
    IELogLevel
IELogWarn -> Text
"WARN"
    IELogLevel
IELogError -> Text
"ERROR"
    IELogLevel
IELogFatal -> Text
"FATAL"

instance FromJSON IELogLevel where
  parseJSON :: Value -> Parser IELogLevel
parseJSON (String Text
s) = forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ case Text
s of
    Text
"TRACE" -> IELogLevel
IELogTrace
    Text
"DEBIG" -> IELogLevel
IELogDebug
    Text
"INFO"  -> IELogLevel
IELogInfo
    Text
"WARN"  -> IELogLevel
IELogWarn
    Text
"ERROR" -> IELogLevel
IELogError
    Text
"FATAL" -> IELogLevel
IELogFatal
    Text
_ -> forall a e. Exception e => e -> a
throw forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> BadJSON
BadJSON forall a b. (a -> b) -> a -> b
$ String
"Invalid logging preference: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Text
s
  parseJSON Value
other = forall a. String -> Value -> Parser a
typeMismatch String
"IELogLevel" Value
other

-- |Specifies how elements scroll into the viewport. (see 'ieElementScrollBehavior')
data IEElementScrollBehavior = AlignTop | AlignBottom
                             deriving (IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
$c/= :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
== :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
$c== :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
Eq, Eq IEElementScrollBehavior
IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
IEElementScrollBehavior -> IEElementScrollBehavior -> Ordering
IEElementScrollBehavior
-> IEElementScrollBehavior -> IEElementScrollBehavior
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: IEElementScrollBehavior
-> IEElementScrollBehavior -> IEElementScrollBehavior
$cmin :: IEElementScrollBehavior
-> IEElementScrollBehavior -> IEElementScrollBehavior
max :: IEElementScrollBehavior
-> IEElementScrollBehavior -> IEElementScrollBehavior
$cmax :: IEElementScrollBehavior
-> IEElementScrollBehavior -> IEElementScrollBehavior
>= :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
$c>= :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
> :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
$c> :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
<= :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
$c<= :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
< :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
$c< :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
compare :: IEElementScrollBehavior -> IEElementScrollBehavior -> Ordering
$ccompare :: IEElementScrollBehavior -> IEElementScrollBehavior -> Ordering
Ord, Int -> IEElementScrollBehavior -> ShowS
[IEElementScrollBehavior] -> ShowS
IEElementScrollBehavior -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IEElementScrollBehavior] -> ShowS
$cshowList :: [IEElementScrollBehavior] -> ShowS
show :: IEElementScrollBehavior -> String
$cshow :: IEElementScrollBehavior -> String
showsPrec :: Int -> IEElementScrollBehavior -> ShowS
$cshowsPrec :: Int -> IEElementScrollBehavior -> ShowS
Show, ReadPrec [IEElementScrollBehavior]
ReadPrec IEElementScrollBehavior
Int -> ReadS IEElementScrollBehavior
ReadS [IEElementScrollBehavior]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IEElementScrollBehavior]
$creadListPrec :: ReadPrec [IEElementScrollBehavior]
readPrec :: ReadPrec IEElementScrollBehavior
$creadPrec :: ReadPrec IEElementScrollBehavior
readList :: ReadS [IEElementScrollBehavior]
$creadList :: ReadS [IEElementScrollBehavior]
readsPrec :: Int -> ReadS IEElementScrollBehavior
$creadsPrec :: Int -> ReadS IEElementScrollBehavior
Read, Int -> IEElementScrollBehavior
IEElementScrollBehavior -> Int
IEElementScrollBehavior -> [IEElementScrollBehavior]
IEElementScrollBehavior -> IEElementScrollBehavior
IEElementScrollBehavior
-> IEElementScrollBehavior -> [IEElementScrollBehavior]
IEElementScrollBehavior
-> IEElementScrollBehavior
-> IEElementScrollBehavior
-> [IEElementScrollBehavior]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: IEElementScrollBehavior
-> IEElementScrollBehavior
-> IEElementScrollBehavior
-> [IEElementScrollBehavior]
$cenumFromThenTo :: IEElementScrollBehavior
-> IEElementScrollBehavior
-> IEElementScrollBehavior
-> [IEElementScrollBehavior]
enumFromTo :: IEElementScrollBehavior
-> IEElementScrollBehavior -> [IEElementScrollBehavior]
$cenumFromTo :: IEElementScrollBehavior
-> IEElementScrollBehavior -> [IEElementScrollBehavior]
enumFromThen :: IEElementScrollBehavior
-> IEElementScrollBehavior -> [IEElementScrollBehavior]
$cenumFromThen :: IEElementScrollBehavior
-> IEElementScrollBehavior -> [IEElementScrollBehavior]
enumFrom :: IEElementScrollBehavior -> [IEElementScrollBehavior]
$cenumFrom :: IEElementScrollBehavior -> [IEElementScrollBehavior]
fromEnum :: IEElementScrollBehavior -> Int
$cfromEnum :: IEElementScrollBehavior -> Int
toEnum :: Int -> IEElementScrollBehavior
$ctoEnum :: Int -> IEElementScrollBehavior
pred :: IEElementScrollBehavior -> IEElementScrollBehavior
$cpred :: IEElementScrollBehavior -> IEElementScrollBehavior
succ :: IEElementScrollBehavior -> IEElementScrollBehavior
$csucc :: IEElementScrollBehavior -> IEElementScrollBehavior
Enum, IEElementScrollBehavior
forall a. a -> a -> Bounded a
maxBound :: IEElementScrollBehavior
$cmaxBound :: IEElementScrollBehavior
minBound :: IEElementScrollBehavior
$cminBound :: IEElementScrollBehavior
Bounded)

instance Default IEElementScrollBehavior where
  def :: IEElementScrollBehavior
def = IEElementScrollBehavior
AlignTop

instance ToJSON IEElementScrollBehavior where
  toJSON :: IEElementScrollBehavior -> Value
toJSON IEElementScrollBehavior
AlignTop    = forall a. ToJSON a => a -> Value
toJSON (Int
0 :: Int)
  toJSON IEElementScrollBehavior
AlignBottom = forall a. ToJSON a => a -> Value
toJSON (Int
1 :: Int)

instance FromJSON IEElementScrollBehavior where
  parseJSON :: Value -> Parser IEElementScrollBehavior
parseJSON Value
v = do
    Integer
n <- forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
    case Integer
n :: Integer of
      Integer
0 -> forall (m :: * -> *) a. Monad m => a -> m a
return IEElementScrollBehavior
AlignTop
      Integer
1 -> forall (m :: * -> *) a. Monad m => a -> m a
return IEElementScrollBehavior
AlignBottom
      Integer
_ -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ String
"Invalid integer for IEElementScrollBehavior: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Integer
n