{-# 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
#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
class GetCapabilities t where
getCaps :: t -> Capabilities
instance GetCapabilities Capabilities where
getCaps :: Capabilities -> Capabilities
getCaps = forall a. a -> a
id
class SetCapabilities t where
setCaps :: Capabilities -> t -> t
type HasCapabilities t = (GetCapabilities t, SetCapabilities t)
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
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 }
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 }
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 }
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 }
data Capabilities =
Capabilities {
Capabilities -> Browser
browser :: Browser
, Capabilities -> Maybe String
version :: Maybe String
, Capabilities -> Platform
platform :: Platform
, Capabilities -> ProxyType
proxy :: ProxyType
, Capabilities -> Maybe Bool
javascriptEnabled :: Maybe Bool
, Capabilities -> Maybe Bool
takesScreenshot :: Maybe Bool
, Capabilities -> Maybe Bool
handlesAlerts :: Maybe Bool
, Capabilities -> Maybe Bool
databaseEnabled :: Maybe Bool
, Capabilities -> Maybe Bool
locationContextEnabled :: Maybe Bool
, Capabilities -> Maybe Bool
applicationCacheEnabled :: Maybe Bool
, Capabilities -> Maybe Bool
browserConnectionEnabled :: Maybe Bool
, Capabilities -> Maybe Bool
cssSelectorsEnabled :: Maybe Bool
, Capabilities -> Maybe Bool
webStorageEnabled :: Maybe Bool
, Capabilities -> Maybe Bool
rotatable :: Maybe Bool
, Capabilities -> Maybe Bool
acceptSSLCerts :: Maybe Bool
, Capabilities -> Maybe Bool
nativeEvents :: Maybe Bool
, Capabilities -> Maybe UnexpectedAlertBehavior
unexpectedAlertBehavior :: Maybe UnexpectedAlertBehavior
, 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 = []
}
defaultCaps :: Capabilities
defaultCaps :: Capabilities
defaultCaps = forall a. Default a => a
def
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
,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
,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 Maybe Word16
operaPort
,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
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
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
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
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
data Browser = Firefox {
Browser -> Maybe (PreparedProfile Firefox)
ffProfile :: Maybe (PreparedProfile Firefox)
, Browser -> LogLevel
ffLogPref :: LogLevel
, Browser -> Maybe String
ffBinary :: Maybe FilePath
, Browser -> Maybe Bool
ffAcceptInsecureCerts :: Maybe Bool
}
| Chrome {
Browser -> Maybe String
chromeDriverVersion :: Maybe String
, Browser -> Maybe String
chromeBinary :: Maybe FilePath
, Browser -> [String]
chromeOptions :: [String]
, Browser -> [ChromeExtension]
chromeExtensions :: [ChromeExtension]
, Browser -> Object
chromeExperimentalOptions :: Object
}
| IE {
Browser -> Bool
ieIgnoreProtectedModeSettings :: Bool
, Browser -> Bool
ieIgnoreZoomSetting :: Bool
, Browser -> Maybe Text
ieInitialBrowserUrl :: Maybe Text
, Browser -> IEElementScrollBehavior
ieElementScrollBehavior :: IEElementScrollBehavior
, Browser -> Bool
ieEnablePersistentHover :: Bool
, Browser -> Bool
ieEnableElementCacheCleanup :: Bool
, Browser -> Bool
ieRequireWindowFocus :: Bool
, Browser -> Integer
ieBrowserAttachTimeout :: Integer
, Browser -> Maybe String
ieLogFile :: Maybe FilePath
, Browser -> IELogLevel
ieLogLevel :: IELogLevel
, Browser -> Maybe Text
ieHost :: Maybe Text
, :: Maybe Text
, Browser -> Bool
ieSilent :: Bool
, Browser -> Bool
ieForceCreateProcess :: Bool
, Browser -> Maybe Text
ieSwitches :: Maybe Text
}
| Opera {
Browser -> Maybe String
operaBinary :: Maybe FilePath
, Browser -> Maybe String
operaProduct :: Maybe String
, Browser -> Bool
operaDetach :: Bool
, Browser -> Bool
operaAutoStart :: Bool
, Browser -> Bool
operaIdle :: Bool
, Browser -> Maybe Int
operaDisplay :: Maybe Int
, Browser -> Maybe String
operaLauncher :: Maybe FilePath
, Browser -> Maybe Word16
operaPort :: Maybe Word16
, Browser -> Maybe String
operaHost :: Maybe String
, Browser -> Maybe String
operaOptions :: Maybe String
, Browser -> Maybe String
operaLogFile :: Maybe FilePath
, Browser -> LogLevel
operaLogPref :: LogLevel
}
| Phantomjs { Browser -> Maybe String
phantomjsBinary :: Maybe FilePath
, Browser -> [String]
phantomjsOptions :: [String]
}
| HTMLUnit
| IPhone
| IPad
| Android
| 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
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
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
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
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
}
opera :: Browser
opera :: Browser
opera = Opera { operaBinary :: Maybe String
operaBinary = forall a. Maybe a
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
, 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 []
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
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
data ProxyType = NoProxy
| UseSystemSettings
| AutoDetect
| PAC { ProxyType -> String
autoConfigUrl :: String }
| 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
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
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
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