module Test.WebDriver.Commands.SeleniumSpecific.Misc (
submit
, isDisplayed
, (<==>)
, (</=>)
) where
import Data.Aeson as A
import GHC.Stack
import Test.WebDriver.JSON
import Test.WebDriver.Types
import Test.WebDriver.Util.Commands
submit :: (HasCallStack, WebDriver wd) => Element -> wd ()
submit :: forall (wd :: * -> *).
(HasCallStack, WebDriver wd) =>
Element -> wd ()
submit Element
e = wd NoReturn -> wd ()
forall (m :: * -> *). WebDriver m => m NoReturn -> m ()
noReturn (wd NoReturn -> wd ()) -> wd NoReturn -> wd ()
forall a b. (a -> b) -> a -> b
$ Method -> Element -> Text -> Value -> wd NoReturn
forall (wd :: * -> *) a b.
(HasCallStack, WebDriver wd, ToJSON a, FromJSON b) =>
Method -> Element -> Text -> a -> wd b
doElemCommand Method
methodPost Element
e Text
"/submit" Value
Null
isDisplayed :: (HasCallStack, WebDriver wd) => Element -> wd Bool
isDisplayed :: forall (wd :: * -> *).
(HasCallStack, WebDriver wd) =>
Element -> wd Bool
isDisplayed Element
e = Method -> Element -> Text -> Value -> wd Bool
forall (wd :: * -> *) a b.
(HasCallStack, WebDriver wd, ToJSON a, FromJSON b) =>
Method -> Element -> Text -> a -> wd b
doElemCommand Method
methodGet Element
e Text
"/displayed" Value
Null
infix 4 <==>
(<==>) :: (HasCallStack, WebDriver wd) => Element -> Element -> wd Bool
Element
e1 <==> :: forall (wd :: * -> *).
(HasCallStack, WebDriver wd) =>
Element -> Element -> wd Bool
<==> (Element Text
e2) = Method -> Element -> Text -> Value -> wd Bool
forall (wd :: * -> *) a b.
(HasCallStack, WebDriver wd, ToJSON a, FromJSON b) =>
Method -> Element -> Text -> a -> wd b
doElemCommand Method
methodGet Element
e1 (Text
"/equals/" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text -> Text
urlEncode Text
e2) Value
Null
infix 4 </=>
(</=>) :: (HasCallStack, WebDriver wd) => Element -> Element -> wd Bool
Element
e1 </=> :: forall (wd :: * -> *).
(HasCallStack, WebDriver wd) =>
Element -> Element -> wd Bool
</=> Element
e2 = Bool -> Bool
not (Bool -> Bool) -> wd Bool -> wd Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Element
e1 Element -> Element -> wd Bool
forall (wd :: * -> *).
(HasCallStack, WebDriver wd) =>
Element -> Element -> wd Bool
<==> Element
e2)