module WebDriverPreCore.HTTP.SpecDefinition
{-# DEPRECATED "Deprecated in favour of \"WebDriverPreCore.HTTP.API\". SpecDefinition module will be removed in a future release ~ 2027-02-01. See ChangeLog.md for upgrade instructions" #-}
(
HttpSpec (..),
newSession,
newSession',
status,
deleteSession,
getTimeouts,
setTimeouts,
navigateTo,
getCurrentUrl,
back,
forward,
refresh,
getTitle,
getWindowHandle,
newWindow,
closeWindow,
switchToWindow,
switchToFrame,
getPageSource,
executeScript,
executeScriptAsync,
addCookie,
getAllCookies,
getNamedCookie,
deleteCookie,
deleteAllCookies,
performActions,
releaseActions,
dismissAlert,
acceptAlert,
getAlertText,
sendAlertText,
takeScreenshot,
printPage,
getWindowHandles,
getWindowRect,
setWindowRect,
maximizeWindow,
minimizeWindow,
fullscreenWindow,
switchToParentFrame,
getActiveElement,
findElement,
findElements,
findElementFromElement,
findElementsFromElement,
isElementSelected,
getElementAttribute,
getElementProperty,
getElementCssValue,
getElementShadowRoot,
getElementText,
getElementTagName,
getElementRect,
isElementEnabled,
getElementComputedRole,
getElementComputedLabel,
elementClick,
elementClear,
elementSendKeys,
takeElementScreenshot,
findElementFromShadowRoot,
findElementsFromShadowRoot,
)
where
import Data.Aeson as A
( FromJSON (..),
KeyValue ((.=)),
Result (..),
ToJSON (toJSON),
Value (..),
object, (.:),
)
import Data.Aeson.Types (parse, Parser)
import Data.Text (Text, unpack)
import WebDriverPreCore.HTTP.HttpResponse (HttpResponse (..))
import WebDriverPreCore.HTTP.Protocol
( Actions (..),
Cookie (..),
ElementId (..),
FrameReference (..),
FullCapabilities (..),
Handle (..),
Script (..),
Selector (..),
Session (..),
SessionResponse (..),
ShadowRootElementId (..),
Status (..),
Timeouts (..),
URL (..),
WindowHandleSpec (..),
WindowRect (..)
)
import AesonUtils (jsonToText)
import Utils (UrlPath (..))
import Prelude hiding (id, lookup)
import Data.Aeson (withObject)
import Control.Monad (when)
import Data.Function ((&))
data HttpSpec a
= Get
{ forall a. HttpSpec a -> Text
description :: Text,
forall a. HttpSpec a -> UrlPath
path :: UrlPath,
forall a. HttpSpec a -> HttpResponse -> Result a
parser :: HttpResponse -> Result a
}
| Post
{ description :: Text,
path :: UrlPath,
forall a. HttpSpec a -> Value
body :: Value,
parser :: HttpResponse -> Result a
}
| PostEmpty
{ description :: Text,
path :: UrlPath,
parser :: HttpResponse -> Result a
}
| Delete
{ description :: Text,
path :: UrlPath,
parser :: HttpResponse -> Result a
}
get :: forall a. (FromJSON a) => Text -> UrlPath -> HttpSpec a
get :: forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
description UrlPath
path =
Text -> UrlPath -> (HttpResponse -> Result a) -> HttpSpec a
forall a.
Text -> UrlPath -> (HttpResponse -> Result a) -> HttpSpec a
Get Text
description UrlPath
path (Bool -> HttpResponse -> Result a
forall a. FromJSON a => Bool -> HttpResponse -> Result a
getParser Bool
False)
post :: forall c r. (ToJSON c, FromJSON r) => Text -> UrlPath -> c -> HttpSpec r
post :: forall c r.
(ToJSON c, FromJSON r) =>
Text -> UrlPath -> c -> HttpSpec r
post Text
description UrlPath
path c
body =
Text
-> UrlPath -> Value -> (HttpResponse -> Result r) -> HttpSpec r
forall a.
Text
-> UrlPath -> Value -> (HttpResponse -> Result a) -> HttpSpec a
Post Text
description UrlPath
path (c -> Value
forall a. ToJSON a => a -> Value
toJSON c
body) (Bool -> HttpResponse -> Result r
forall a. FromJSON a => Bool -> HttpResponse -> Result a
getParser Bool
False)
post_ :: forall c. (ToJSON c) => Text -> UrlPath -> c -> HttpSpec ()
post_ :: forall c. ToJSON c => Text -> UrlPath -> c -> HttpSpec ()
post_ Text
description UrlPath
path c
body =
Text
-> UrlPath -> Value -> (HttpResponse -> Result ()) -> HttpSpec ()
forall a.
Text
-> UrlPath -> Value -> (HttpResponse -> Result a) -> HttpSpec a
Post Text
description UrlPath
path (c -> Value
forall a. ToJSON a => a -> Value
toJSON c
body) (Bool -> HttpResponse -> Result ()
forall a. FromJSON a => Bool -> HttpResponse -> Result a
getParser Bool
True)
postEmpty :: forall a. (FromJSON a) => Text -> UrlPath -> HttpSpec a
postEmpty :: forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
postEmpty Text
description UrlPath
path =
Text -> UrlPath -> (HttpResponse -> Result a) -> HttpSpec a
forall a.
Text -> UrlPath -> (HttpResponse -> Result a) -> HttpSpec a
PostEmpty Text
description UrlPath
path (Bool -> HttpResponse -> Result a
forall a. FromJSON a => Bool -> HttpResponse -> Result a
getParser Bool
False)
postEmpty_ :: Text -> UrlPath -> HttpSpec ()
postEmpty_ :: Text -> UrlPath -> HttpSpec ()
postEmpty_ Text
description UrlPath
path =
Text -> UrlPath -> (HttpResponse -> Result ()) -> HttpSpec ()
forall a.
Text -> UrlPath -> (HttpResponse -> Result a) -> HttpSpec a
PostEmpty Text
description UrlPath
path (Bool -> HttpResponse -> Result ()
forall a. FromJSON a => Bool -> HttpResponse -> Result a
getParser Bool
True)
delete :: forall a. (FromJSON a) => Text -> UrlPath -> HttpSpec a
delete :: forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
delete Text
description UrlPath
path =
Text -> UrlPath -> (HttpResponse -> Result a) -> HttpSpec a
forall a.
Text -> UrlPath -> (HttpResponse -> Result a) -> HttpSpec a
Delete Text
description UrlPath
path (Bool -> HttpResponse -> Result a
forall a. FromJSON a => Bool -> HttpResponse -> Result a
getParser Bool
False)
delete_ :: Text -> UrlPath -> HttpSpec ()
delete_ :: Text -> UrlPath -> HttpSpec ()
delete_ Text
description UrlPath
path =
Text -> UrlPath -> (HttpResponse -> Result ()) -> HttpSpec ()
forall a.
Text -> UrlPath -> (HttpResponse -> Result a) -> HttpSpec a
Delete Text
description UrlPath
path (Bool -> HttpResponse -> Result ()
forall a. FromJSON a => Bool -> HttpResponse -> Result a
getParser Bool
True)
getParser :: forall a. (FromJSON a) => Bool -> HttpResponse -> Result a
getParser :: forall a. FromJSON a => Bool -> HttpResponse -> Result a
getParser Bool
expectNull HttpResponse
r = (Value -> Parser a) -> Value -> Result a
forall a b. (a -> Parser b) -> a -> Result b
parse (Bool -> Value -> Parser a
forall a. FromJSON a => Bool -> Value -> Parser a
fromBodyValue Bool
expectNull) HttpResponse
r.body
fromBodyValue :: forall a. (FromJSON a) => Bool -> Value -> Parser a
fromBodyValue :: forall a. FromJSON a => Bool -> Value -> Parser a
fromBodyValue Bool
expectNull Value
body =
Value
body Value -> (Value -> Parser a) -> Parser a
forall a b. a -> (a -> b) -> b
& String -> (Object -> Parser a) -> Value -> Parser a
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"body value" \Object
b -> do
val <- Object
b Object -> Key -> Parser Value
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"value"
when (expectNull && val /= Null) $
fail $
unpack $
"Null value expected but got:\n" <> jsonToText val
parseJSON $ val
instance (Show a) => Show (HttpSpec a) where
show :: HttpSpec a -> String
show :: HttpSpec a -> String
show = HttpSpecShowable -> String
forall a. Show a => a -> String
Prelude.show (HttpSpecShowable -> String)
-> (HttpSpec a -> HttpSpecShowable) -> HttpSpec a -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HttpSpec a -> HttpSpecShowable
forall a. HttpSpec a -> HttpSpecShowable
mkShowable
data HttpSpecShowable = Request
{ HttpSpecShowable -> Text
description :: Text,
HttpSpecShowable -> Text
method :: Text,
HttpSpecShowable -> UrlPath
path :: UrlPath,
HttpSpecShowable -> Maybe Text
body :: Maybe Text
}
deriving (Int -> HttpSpecShowable -> ShowS
[HttpSpecShowable] -> ShowS
HttpSpecShowable -> String
(Int -> HttpSpecShowable -> ShowS)
-> (HttpSpecShowable -> String)
-> ([HttpSpecShowable] -> ShowS)
-> Show HttpSpecShowable
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HttpSpecShowable -> ShowS
showsPrec :: Int -> HttpSpecShowable -> ShowS
$cshow :: HttpSpecShowable -> String
show :: HttpSpecShowable -> String
$cshowList :: [HttpSpecShowable] -> ShowS
showList :: [HttpSpecShowable] -> ShowS
Show)
mkShowable :: HttpSpec a -> HttpSpecShowable
mkShowable :: forall a. HttpSpec a -> HttpSpecShowable
mkShowable = \case
Get Text
d UrlPath
p HttpResponse -> Result a
_ -> Text -> Text -> UrlPath -> Maybe Text -> HttpSpecShowable
Request Text
d Text
"GET" UrlPath
p Maybe Text
forall a. Maybe a
Nothing
Post Text
d UrlPath
p Value
b HttpResponse -> Result a
_ -> Text -> Text -> UrlPath -> Maybe Text -> HttpSpecShowable
Request Text
d Text
"POST" UrlPath
p (Text -> Maybe Text
forall a. a -> Maybe a
Just (Text -> Maybe Text) -> Text -> Maybe Text
forall a b. (a -> b) -> a -> b
$ Value -> Text
jsonToText Value
b)
PostEmpty Text
d UrlPath
p HttpResponse -> Result a
_ -> Text -> Text -> UrlPath -> Maybe Text -> HttpSpecShowable
Request Text
d Text
"POST" UrlPath
p Maybe Text
forall a. Maybe a
Nothing
Delete Text
d UrlPath
p HttpResponse -> Result a
_ -> Text -> Text -> UrlPath -> Maybe Text -> HttpSpecShowable
Request Text
d Text
"DELETE" UrlPath
p Maybe Text
forall a. Maybe a
Nothing
newSession :: FullCapabilities -> HttpSpec SessionResponse
newSession :: FullCapabilities -> HttpSpec SessionResponse
newSession = FullCapabilities -> HttpSpec SessionResponse
forall a. ToJSON a => a -> HttpSpec SessionResponse
newSession'
newSession' :: (ToJSON a) => a -> HttpSpec SessionResponse
newSession' :: forall a. ToJSON a => a -> HttpSpec SessionResponse
newSession' = Text -> UrlPath -> a -> HttpSpec SessionResponse
forall c r.
(ToJSON c, FromJSON r) =>
Text -> UrlPath -> c -> HttpSpec r
post Text
"New Session" UrlPath
newSessionUrl
status :: HttpSpec Status
status :: HttpSpec Status
status = Text -> UrlPath -> HttpSpec Status
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Status" ([Text] -> UrlPath
MkUrlPath [Text
"status"])
deleteSession :: Session -> HttpSpec ()
deleteSession :: Session -> HttpSpec ()
deleteSession Session
sessionRef = Text -> UrlPath -> HttpSpec ()
delete_ Text
"Delete Session" (Text -> UrlPath
sessionUri Session
sessionRef.id)
getTimeouts :: Session -> HttpSpec Timeouts
getTimeouts :: Session -> HttpSpec Timeouts
getTimeouts Session
sessionRef = Text -> UrlPath -> HttpSpec Timeouts
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Get Timeouts" (Session -> Text -> UrlPath
sessionUri1 Session
sessionRef Text
"timeouts")
setTimeouts :: Session -> Timeouts -> HttpSpec ()
setTimeouts :: Session -> Timeouts -> HttpSpec ()
setTimeouts Session
sessionRef Timeouts
timeouts =
Text -> UrlPath -> Value -> HttpSpec ()
forall c. ToJSON c => Text -> UrlPath -> c -> HttpSpec ()
post_ Text
"Set Timeouts" (Session -> Text -> UrlPath
sessionUri1 Session
sessionRef Text
"timeouts") (Timeouts -> Value
forall a. ToJSON a => a -> Value
toJSON Timeouts
timeouts)
navigateTo :: Session -> URL -> HttpSpec ()
navigateTo :: Session -> URL -> HttpSpec ()
navigateTo Session
sessionRef URL
url = Text -> UrlPath -> Value -> HttpSpec ()
forall c. ToJSON c => Text -> UrlPath -> c -> HttpSpec ()
post_ Text
"Navigate To" (Session -> Text -> UrlPath
sessionUri1 Session
sessionRef Text
"url") ([Pair] -> Value
object [Key
"url" Key -> URL -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= URL
url])
getCurrentUrl :: Session -> HttpSpec URL
getCurrentUrl :: Session -> HttpSpec URL
getCurrentUrl Session
sessionRef = Text -> UrlPath -> HttpSpec URL
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Get Current URL" (Session -> Text -> UrlPath
sessionUri1 Session
sessionRef Text
"url")
back :: Session -> HttpSpec ()
back :: Session -> HttpSpec ()
back Session
sessionRef = Text -> UrlPath -> HttpSpec ()
postEmpty_ Text
"Back" (Session -> Text -> UrlPath
sessionUri1 Session
sessionRef Text
"back")
forward :: Session -> HttpSpec ()
forward :: Session -> HttpSpec ()
forward Session
sessionRef = Text -> UrlPath -> HttpSpec ()
postEmpty_ Text
"Forward" (Session -> Text -> UrlPath
sessionUri1 Session
sessionRef Text
"forward")
refresh :: Session -> HttpSpec ()
refresh :: Session -> HttpSpec ()
refresh Session
sessionRef = Text -> UrlPath -> HttpSpec ()
postEmpty_ Text
"Refresh" (Session -> Text -> UrlPath
sessionUri1 Session
sessionRef Text
"refresh")
getTitle :: Session -> HttpSpec Text
getTitle :: Session -> HttpSpec Text
getTitle Session
sessionRef = Text -> UrlPath -> HttpSpec Text
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Get Title" (Session -> Text -> UrlPath
sessionUri1 Session
sessionRef Text
"title")
getWindowHandle :: Session -> HttpSpec Handle
getWindowHandle :: Session -> HttpSpec Handle
getWindowHandle Session
sessionRef = Text -> UrlPath -> HttpSpec Handle
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Get Window Handle" (Session -> Text -> UrlPath
sessionUri1 Session
sessionRef Text
"window")
newWindow :: Session -> HttpSpec WindowHandleSpec
newWindow :: Session -> HttpSpec WindowHandleSpec
newWindow Session
sessionRef = Text -> UrlPath -> HttpSpec WindowHandleSpec
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
postEmpty Text
"New Window" (Session -> Text -> Text -> UrlPath
sessionUri2 Session
sessionRef Text
"window" Text
"new")
closeWindow :: Session -> HttpSpec [Handle]
closeWindow :: Session -> HttpSpec [Handle]
closeWindow Session
sessionRef = Text -> UrlPath -> HttpSpec [Handle]
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
delete Text
"Close Window" (Session -> Text -> UrlPath
sessionUri1 Session
sessionRef Text
"window")
switchToWindow :: Session -> Handle -> HttpSpec ()
switchToWindow :: Session -> Handle -> HttpSpec ()
switchToWindow Session
sessionRef MkHandle {Text
handle :: Text
handle :: Handle -> Text
handle} = Text -> UrlPath -> Value -> HttpSpec ()
forall c. ToJSON c => Text -> UrlPath -> c -> HttpSpec ()
post_ Text
"Switch To Window" (Session -> Text -> UrlPath
sessionUri1 Session
sessionRef Text
"window") ([Pair] -> Value
object [Key
"handle" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text
handle])
switchToFrame :: Session -> FrameReference -> HttpSpec ()
switchToFrame :: Session -> FrameReference -> HttpSpec ()
switchToFrame Session
sessionRef FrameReference
frameRef = Text -> UrlPath -> Value -> HttpSpec ()
forall c. ToJSON c => Text -> UrlPath -> c -> HttpSpec ()
post_ Text
"Switch To Frame" (Session -> Text -> UrlPath
sessionUri1 Session
sessionRef Text
"frame") (FrameReference -> Value
forall a. ToJSON a => a -> Value
toJSON FrameReference
frameRef)
getPageSource :: Session -> HttpSpec Text
getPageSource :: Session -> HttpSpec Text
getPageSource Session
sessionId = Text -> UrlPath -> HttpSpec Text
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Get Page Source" (Session -> Text -> UrlPath
sessionUri1 Session
sessionId Text
"source")
executeScript :: Session -> Script -> HttpSpec Value
executeScript :: Session -> Script -> HttpSpec Value
executeScript Session
sessionId Script
script = Text -> UrlPath -> Value -> HttpSpec Value
forall c r.
(ToJSON c, FromJSON r) =>
Text -> UrlPath -> c -> HttpSpec r
post Text
"Execute Script" (Session -> Text -> Text -> UrlPath
sessionUri2 Session
sessionId Text
"execute" Text
"sync") (Script -> Value
forall a. ToJSON a => a -> Value
toJSON Script
script)
executeScriptAsync :: Session -> Script -> HttpSpec Value
executeScriptAsync :: Session -> Script -> HttpSpec Value
executeScriptAsync Session
sessionId Script
script = Text -> UrlPath -> Script -> HttpSpec Value
forall c r.
(ToJSON c, FromJSON r) =>
Text -> UrlPath -> c -> HttpSpec r
post Text
"Execute Async Script" (Session -> Text -> Text -> UrlPath
sessionUri2 Session
sessionId Text
"execute" Text
"async") Script
script
getAllCookies :: Session -> HttpSpec [Cookie]
getAllCookies :: Session -> HttpSpec [Cookie]
getAllCookies Session
sessionId = Text -> UrlPath -> HttpSpec [Cookie]
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Get All Cookies" (Session -> Text -> UrlPath
sessionUri1 Session
sessionId Text
"cookie")
getNamedCookie :: Session -> Text -> HttpSpec Cookie
getNamedCookie :: Session -> Text -> HttpSpec Cookie
getNamedCookie Session
sessionId Text
cookieName = Text -> UrlPath -> HttpSpec Cookie
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Get Named Cookie" (Session -> Text -> Text -> UrlPath
sessionUri2 Session
sessionId Text
"cookie" Text
cookieName)
addCookie :: Session -> Cookie -> HttpSpec ()
addCookie :: Session -> Cookie -> HttpSpec ()
addCookie Session
sessionId Cookie
cookie = Text -> UrlPath -> Value -> HttpSpec ()
forall c. ToJSON c => Text -> UrlPath -> c -> HttpSpec ()
post_ Text
"Add Cookie" (Session -> Text -> UrlPath
sessionUri1 Session
sessionId Text
"cookie") ([Pair] -> Value
object [Key
"cookie" Key -> Cookie -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Cookie
cookie])
deleteCookie :: Session -> Text -> HttpSpec ()
deleteCookie :: Session -> Text -> HttpSpec ()
deleteCookie Session
sessionId Text
cookieName = Text -> UrlPath -> HttpSpec ()
delete_ Text
"Delete Cookie" (Session -> Text -> Text -> UrlPath
sessionUri2 Session
sessionId Text
"cookie" Text
cookieName)
deleteAllCookies :: Session -> HttpSpec ()
deleteAllCookies :: Session -> HttpSpec ()
deleteAllCookies Session
sessionId = Text -> UrlPath -> HttpSpec ()
delete_ Text
"Delete All Cookies" (Session -> Text -> UrlPath
sessionUri1 Session
sessionId Text
"cookie")
performActions :: Session -> Actions -> HttpSpec ()
performActions :: Session -> Actions -> HttpSpec ()
performActions Session
sessionId Actions
actions = Text -> UrlPath -> Value -> HttpSpec ()
forall c. ToJSON c => Text -> UrlPath -> c -> HttpSpec ()
post_ Text
"Perform Actions" (Session -> Text -> UrlPath
sessionUri1 Session
sessionId Text
"actions") (Actions -> Value
forall a. ToJSON a => a -> Value
toJSON Actions
actions)
releaseActions :: Session -> HttpSpec ()
releaseActions :: Session -> HttpSpec ()
releaseActions Session
sessionId = Text -> UrlPath -> HttpSpec ()
delete_ Text
"Release Actions" (Session -> Text -> UrlPath
sessionUri1 Session
sessionId Text
"actions")
dismissAlert :: Session -> HttpSpec ()
dismissAlert :: Session -> HttpSpec ()
dismissAlert Session
sessionId = Text -> UrlPath -> HttpSpec ()
postEmpty_ Text
"Dismiss Alert" (Session -> Text -> Text -> UrlPath
sessionUri2 Session
sessionId Text
"alert" Text
"dismiss")
acceptAlert :: Session -> HttpSpec ()
acceptAlert :: Session -> HttpSpec ()
acceptAlert Session
sessionId = Text -> UrlPath -> HttpSpec ()
postEmpty_ Text
"Accept Alert" (Session -> Text -> Text -> UrlPath
sessionUri2 Session
sessionId Text
"alert" Text
"accept")
getAlertText :: Session -> HttpSpec Text
getAlertText :: Session -> HttpSpec Text
getAlertText Session
sessionId = Text -> UrlPath -> HttpSpec Text
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Get Alert Text" (Session -> Text -> Text -> UrlPath
sessionUri2 Session
sessionId Text
"alert" Text
"text")
sendAlertText :: Session -> Text -> HttpSpec ()
sendAlertText :: Session -> Text -> HttpSpec ()
sendAlertText Session
sessionId Text
text = Text -> UrlPath -> Value -> HttpSpec ()
forall c. ToJSON c => Text -> UrlPath -> c -> HttpSpec ()
post_ Text
"Send Alert Text" (Session -> Text -> Text -> UrlPath
sessionUri2 Session
sessionId Text
"alert" Text
"text") ([Pair] -> Value
object [Key
"text" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text
text])
takeScreenshot :: Session -> HttpSpec Text
takeScreenshot :: Session -> HttpSpec Text
takeScreenshot Session
sessionId = Text -> UrlPath -> HttpSpec Text
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Take Screenshot" (Session -> Text -> UrlPath
sessionUri1 Session
sessionId Text
"screenshot")
printPage :: Session -> HttpSpec Text
printPage :: Session -> HttpSpec Text
printPage Session
sessionId = Text -> UrlPath -> HttpSpec Text
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
postEmpty Text
"Print Page" (Session -> Text -> UrlPath
sessionUri1 Session
sessionId Text
"print")
getWindowHandles :: Session -> HttpSpec [Handle]
getWindowHandles :: Session -> HttpSpec [Handle]
getWindowHandles Session
sessionRef = Text -> UrlPath -> HttpSpec [Handle]
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Get Window Handles" (Session -> Text -> Text -> UrlPath
sessionUri2 Session
sessionRef Text
"window" Text
"handles")
getWindowRect :: Session -> HttpSpec WindowRect
getWindowRect :: Session -> HttpSpec WindowRect
getWindowRect Session
sessionRef = Text -> UrlPath -> HttpSpec WindowRect
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Get Window Rect" (Session -> Text -> Text -> UrlPath
sessionUri2 Session
sessionRef Text
"window" Text
"rect")
setWindowRect :: Session -> WindowRect -> HttpSpec WindowRect
setWindowRect :: Session -> WindowRect -> HttpSpec WindowRect
setWindowRect Session
sessionRef = Text -> UrlPath -> WindowRect -> HttpSpec WindowRect
forall c r.
(ToJSON c, FromJSON r) =>
Text -> UrlPath -> c -> HttpSpec r
post Text
"Set Window Rect" (Session -> Text -> Text -> UrlPath
sessionUri2 Session
sessionRef Text
"window" Text
"rect")
maximizeWindow :: Session -> HttpSpec WindowRect
maximizeWindow :: Session -> HttpSpec WindowRect
maximizeWindow Session
sessionRef = Text -> UrlPath -> HttpSpec WindowRect
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
postEmpty Text
"Maximize Window" (Session -> Text -> UrlPath
windowUri1 Session
sessionRef Text
"maximize")
minimizeWindow :: Session -> HttpSpec WindowRect
minimizeWindow :: Session -> HttpSpec WindowRect
minimizeWindow Session
sessionRef = Text -> UrlPath -> HttpSpec WindowRect
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
postEmpty Text
"Minimize Window" (Session -> Text -> UrlPath
windowUri1 Session
sessionRef Text
"minimize")
fullscreenWindow :: Session -> HttpSpec WindowRect
fullscreenWindow :: Session -> HttpSpec WindowRect
fullscreenWindow Session
sessionRef = Text -> UrlPath -> HttpSpec WindowRect
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
postEmpty Text
"Fullscreen Window" (Session -> Text -> UrlPath
windowUri1 Session
sessionRef Text
"fullscreen")
switchToParentFrame :: Session -> HttpSpec ()
switchToParentFrame :: Session -> HttpSpec ()
switchToParentFrame Session
sessionRef = Text -> UrlPath -> HttpSpec ()
postEmpty_ Text
"Switch To Parent Frame" (Session -> Text -> Text -> UrlPath
sessionUri2 Session
sessionRef Text
"frame" Text
"parent")
getActiveElement :: Session -> HttpSpec ElementId
getActiveElement :: Session -> HttpSpec ElementId
getActiveElement Session
sessionId = Text -> UrlPath -> HttpSpec ElementId
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Get Active Element" (Session -> Text -> Text -> UrlPath
sessionUri2 Session
sessionId Text
"element" Text
"active")
findElement :: Session -> Selector -> HttpSpec ElementId
findElement :: Session -> Selector -> HttpSpec ElementId
findElement Session
sessionRef = Text -> UrlPath -> Selector -> HttpSpec ElementId
forall c r.
(ToJSON c, FromJSON r) =>
Text -> UrlPath -> c -> HttpSpec r
post Text
"Find Element" (Session -> Text -> UrlPath
sessionUri1 Session
sessionRef Text
"element")
findElements :: Session -> Selector -> HttpSpec [ElementId]
findElements :: Session -> Selector -> HttpSpec [ElementId]
findElements Session
sessionRef = Text -> UrlPath -> Selector -> HttpSpec [ElementId]
forall c r.
(ToJSON c, FromJSON r) =>
Text -> UrlPath -> c -> HttpSpec r
post Text
"Find Elements" (Session -> Text -> UrlPath
sessionUri1 Session
sessionRef Text
"elements")
getElementShadowRoot :: Session -> ElementId -> HttpSpec ShadowRootElementId
getElementShadowRoot :: Session -> ElementId -> HttpSpec ShadowRootElementId
getElementShadowRoot Session
sessionId ElementId
elementId = Text -> UrlPath -> HttpSpec ShadowRootElementId
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Get Element Shadow Root" (Session -> ElementId -> Text -> UrlPath
elementUri1 Session
sessionId ElementId
elementId Text
"shadow")
findElementFromElement :: Session -> ElementId -> Selector -> HttpSpec ElementId
findElementFromElement :: Session -> ElementId -> Selector -> HttpSpec ElementId
findElementFromElement Session
sessionId ElementId
elementId = Text -> UrlPath -> Selector -> HttpSpec ElementId
forall c r.
(ToJSON c, FromJSON r) =>
Text -> UrlPath -> c -> HttpSpec r
post Text
"Find Element From Element" (Session -> ElementId -> Text -> UrlPath
elementUri1 Session
sessionId ElementId
elementId Text
"element")
findElementsFromElement :: Session -> ElementId -> Selector -> HttpSpec [ElementId]
findElementsFromElement :: Session -> ElementId -> Selector -> HttpSpec [ElementId]
findElementsFromElement Session
sessionId ElementId
elementId = Text -> UrlPath -> Selector -> HttpSpec [ElementId]
forall c r.
(ToJSON c, FromJSON r) =>
Text -> UrlPath -> c -> HttpSpec r
post Text
"Find Elements From Element" (Session -> ElementId -> Text -> UrlPath
elementUri1 Session
sessionId ElementId
elementId Text
"elements")
isElementSelected :: Session -> ElementId -> HttpSpec Bool
isElementSelected :: Session -> ElementId -> HttpSpec Bool
isElementSelected Session
sessionId ElementId
elementId = Text -> UrlPath -> HttpSpec Bool
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Is Element Selected" (Session -> ElementId -> Text -> UrlPath
elementUri1 Session
sessionId ElementId
elementId Text
"selected")
getElementAttribute :: Session -> ElementId -> Text -> HttpSpec Text
getElementAttribute :: Session -> ElementId -> Text -> HttpSpec Text
getElementAttribute Session
sessionId ElementId
elementId Text
attributeName = Text -> UrlPath -> HttpSpec Text
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Get Element Attribute" (Session -> ElementId -> Text -> Text -> UrlPath
elementUri2 Session
sessionId ElementId
elementId Text
"attribute" Text
attributeName)
getElementProperty :: Session -> ElementId -> Text -> HttpSpec Value
getElementProperty :: Session -> ElementId -> Text -> HttpSpec Value
getElementProperty Session
sessionId ElementId
elementId Text
propertyName = Text -> UrlPath -> HttpSpec Value
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Get Element Property" (Session -> ElementId -> Text -> Text -> UrlPath
elementUri2 Session
sessionId ElementId
elementId Text
"property" Text
propertyName)
getElementCssValue :: Session -> ElementId -> Text -> HttpSpec Text
getElementCssValue :: Session -> ElementId -> Text -> HttpSpec Text
getElementCssValue Session
sessionId ElementId
elementId Text
propertyName = Text -> UrlPath -> HttpSpec Text
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Get Element CSS Value" (Session -> ElementId -> Text -> Text -> UrlPath
elementUri2 Session
sessionId ElementId
elementId Text
"css" Text
propertyName)
getElementText :: Session -> ElementId -> HttpSpec Text
getElementText :: Session -> ElementId -> HttpSpec Text
getElementText Session
sessionId ElementId
elementId = Text -> UrlPath -> HttpSpec Text
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Get Element Text" (Session -> ElementId -> Text -> UrlPath
elementUri1 Session
sessionId ElementId
elementId Text
"text")
getElementTagName :: Session -> ElementId -> HttpSpec Text
getElementTagName :: Session -> ElementId -> HttpSpec Text
getElementTagName Session
sessionId ElementId
elementId = Text -> UrlPath -> HttpSpec Text
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Get Element Tag Name" (Session -> ElementId -> Text -> UrlPath
elementUri1 Session
sessionId ElementId
elementId Text
"name")
getElementRect :: Session -> ElementId -> HttpSpec WindowRect
getElementRect :: Session -> ElementId -> HttpSpec WindowRect
getElementRect Session
sessionId ElementId
elementId = Text -> UrlPath -> HttpSpec WindowRect
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Get Element Rect" (Session -> ElementId -> Text -> UrlPath
elementUri1 Session
sessionId ElementId
elementId Text
"rect")
isElementEnabled :: Session -> ElementId -> HttpSpec Bool
isElementEnabled :: Session -> ElementId -> HttpSpec Bool
isElementEnabled Session
sessionId ElementId
elementId = Text -> UrlPath -> HttpSpec Bool
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Is Element Enabled" (Session -> ElementId -> Text -> UrlPath
elementUri1 Session
sessionId ElementId
elementId Text
"enabled")
getElementComputedRole :: Session -> ElementId -> HttpSpec Text
getElementComputedRole :: Session -> ElementId -> HttpSpec Text
getElementComputedRole Session
sessionId ElementId
elementId = Text -> UrlPath -> HttpSpec Text
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Get Computed Role" (Session -> ElementId -> Text -> UrlPath
elementUri1 Session
sessionId ElementId
elementId Text
"computedrole")
getElementComputedLabel :: Session -> ElementId -> HttpSpec Text
getElementComputedLabel :: Session -> ElementId -> HttpSpec Text
getElementComputedLabel Session
sessionId ElementId
elementId = Text -> UrlPath -> HttpSpec Text
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Get Computed Label" (Session -> ElementId -> Text -> UrlPath
elementUri1 Session
sessionId ElementId
elementId Text
"computedlabel")
elementClick :: Session -> ElementId -> HttpSpec ()
elementClick :: Session -> ElementId -> HttpSpec ()
elementClick Session
sessionId ElementId
elementId = Text -> UrlPath -> HttpSpec ()
postEmpty_ Text
"Element Click" (Session -> ElementId -> Text -> UrlPath
elementUri1 Session
sessionId ElementId
elementId Text
"click")
elementClear :: Session -> ElementId -> HttpSpec ()
elementClear :: Session -> ElementId -> HttpSpec ()
elementClear Session
sessionId ElementId
elementId = Text -> UrlPath -> HttpSpec ()
postEmpty_ Text
"Element Clear" (Session -> ElementId -> Text -> UrlPath
elementUri1 Session
sessionId ElementId
elementId Text
"clear")
elementSendKeys :: Session -> ElementId -> Text -> HttpSpec ()
elementSendKeys :: Session -> ElementId -> Text -> HttpSpec ()
elementSendKeys Session
sessionId ElementId
elementId Text
keysToSend = Text -> UrlPath -> Value -> HttpSpec ()
forall c. ToJSON c => Text -> UrlPath -> c -> HttpSpec ()
post_ Text
"Element Send Keys" (Session -> ElementId -> Text -> UrlPath
elementUri1 Session
sessionId ElementId
elementId Text
"value") ([Pair] -> Value
object [Key
"text" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text
keysToSend])
takeElementScreenshot :: Session -> ElementId -> HttpSpec Text
takeElementScreenshot :: Session -> ElementId -> HttpSpec Text
takeElementScreenshot Session
sessionId ElementId
elementId = Text -> UrlPath -> HttpSpec Text
forall a. FromJSON a => Text -> UrlPath -> HttpSpec a
get Text
"Take Element Screenshot" (Session -> ElementId -> Text -> UrlPath
elementUri1 Session
sessionId ElementId
elementId Text
"screenshot")
findElementFromShadowRoot :: Session -> ShadowRootElementId -> Selector -> HttpSpec ElementId
findElementFromShadowRoot :: Session -> ShadowRootElementId -> Selector -> HttpSpec ElementId
findElementFromShadowRoot Session
sessionId ShadowRootElementId
shadowId = Text -> UrlPath -> Selector -> HttpSpec ElementId
forall c r.
(ToJSON c, FromJSON r) =>
Text -> UrlPath -> c -> HttpSpec r
post Text
"Find Element From Shadow Root" (Session -> Text -> Text -> Text -> UrlPath
sessionUri3 Session
sessionId Text
"shadow" ShadowRootElementId
shadowId.id Text
"element")
findElementsFromShadowRoot :: Session -> ShadowRootElementId -> Selector -> HttpSpec [ElementId]
findElementsFromShadowRoot :: Session -> ShadowRootElementId -> Selector -> HttpSpec [ElementId]
findElementsFromShadowRoot Session
sessionId ShadowRootElementId
shadowId = Text -> UrlPath -> Selector -> HttpSpec [ElementId]
forall c r.
(ToJSON c, FromJSON r) =>
Text -> UrlPath -> c -> HttpSpec r
post Text
"Find Elements From Shadow Root" (Session -> Text -> Text -> Text -> UrlPath
sessionUri3 Session
sessionId Text
"shadow" ShadowRootElementId
shadowId.id Text
"elements")
sessionUri :: Text -> UrlPath
sessionUri :: Text -> UrlPath
sessionUri Text
sp = [Text] -> UrlPath
MkUrlPath [Text
session, Text
sp]
sessionUri1 :: Session -> Text -> UrlPath
sessionUri1 :: Session -> Text -> UrlPath
sessionUri1 Session
s Text
sp = [Text] -> UrlPath
MkUrlPath [Text
session, Session
s.id, Text
sp]
sessionUri2 :: Session -> Text -> Text -> UrlPath
sessionUri2 :: Session -> Text -> Text -> UrlPath
sessionUri2 Session
s Text
sp Text
sp2 = [Text] -> UrlPath
MkUrlPath [Text
session, Session
s.id, Text
sp, Text
sp2]
sessionUri3 :: Session -> Text -> Text -> Text -> UrlPath
sessionUri3 :: Session -> Text -> Text -> Text -> UrlPath
sessionUri3 Session
s Text
sp Text
sp2 Text
sp3 = [Text] -> UrlPath
MkUrlPath [Text
session, Session
s.id, Text
sp, Text
sp2, Text
sp3]
sessionUri4 :: Session -> Text -> Text -> Text -> Text -> UrlPath
sessionUri4 :: Session -> Text -> Text -> Text -> Text -> UrlPath
sessionUri4 Session
s Text
sp Text
sp2 Text
sp3 Text
sp4 = [Text] -> UrlPath
MkUrlPath [Text
session, Session
s.id, Text
sp, Text
sp2, Text
sp3, Text
sp4]
window :: Text
window :: Text
window = Text
"window"
windowUri1 :: Session -> Text -> UrlPath
windowUri1 :: Session -> Text -> UrlPath
windowUri1 Session
sr Text
sp = Session -> Text -> Text -> UrlPath
sessionUri2 Session
sr Text
window Text
sp
elementUri1 :: Session -> ElementId -> Text -> UrlPath
elementUri1 :: Session -> ElementId -> Text -> UrlPath
elementUri1 Session
s ElementId
er Text
ep = Session -> Text -> Text -> Text -> UrlPath
sessionUri3 Session
s Text
"element" ElementId
er.id Text
ep
elementUri2 :: Session -> ElementId -> Text -> Text -> UrlPath
elementUri2 :: Session -> ElementId -> Text -> Text -> UrlPath
elementUri2 Session
s ElementId
er Text
ep Text
ep2 = Session -> Text -> Text -> Text -> Text -> UrlPath
sessionUri4 Session
s Text
"element" ElementId
er.id Text
ep Text
ep2
newSessionUrl :: UrlPath
newSessionUrl :: UrlPath
newSessionUrl = [Text] -> UrlPath
MkUrlPath [Text
session]
session :: Text
session :: Text
session = Text
"session"