Module
Selenium.Monad
- Package
- purescript-webdriver
- Repository
- slamdata/purescript-webdriver
Most functions of Selenium
use Driver
as an argument
This module supposed to make code a bit cleaner through
putting Driver
to ReaderT
#Selenium Source
type Selenium e o = ReaderT { defaultTimeout :: Milliseconds, driver :: Driver | o } Aff
Driver
is field of ReaderT
context
Usually selenium tests are run with tons of configs (i.e. xpath locators,
timeouts) all those configs can be putted to Selenium e o a
#getWindowPosition Source
getWindowPosition :: forall o e. Selenium e o Location
#getWindowSize Source
getWindowSize :: forall o e. Selenium e o Size
#maximizeWindow Source
maximizeWindow :: forall o e. Selenium e o Unit
#getWindowScroll Source
getWindowScroll :: forall o e. Selenium e o Location
#tryRepeatedlyTo' Source
tryRepeatedlyTo' :: forall o e a d. Duration d => d -> Selenium e o a -> Selenium e o a
Tries the provided Selenium computation repeatedly until the provided timeout expires
#tryRepeatedlyTo Source
tryRepeatedlyTo :: forall o e a. Selenium e o a -> Selenium e o a
Tries the provided Selenium computation repeatedly until Selenium
's defaultTimeout expires
#locator Source
locator :: forall o e. (Element -> Selenium e o Element) -> Selenium e o Locator
get element by action returning an element
locator \el → do
commonElements ← byCss ".common-element" >>= findElements el
flaggedElements ← traverse (\el → Tuple el <$> isVisible el) commonElements
maybe err pure $ foldl foldFn Nothing flaggedElements
where
err = throwError $ error "all common elements are not visible"
foldFn Nothing (Tuple el true) = Just el
foldFn a _ = a
#findElement Source
findElement :: forall o e. Locator -> Selenium e o (Maybe Element)
Tries to find element and return it wrapped in Just
#getCurrentUrl Source
getCurrentUrl :: forall o e. Selenium e o String
#setFileDetector Source
setFileDetector :: forall o e. FileDetector -> Selenium e o Unit
#takeScreenshot Source
takeScreenshot :: forall o e. Selenium e o String
#loseElement Source
loseElement :: forall o e. Locator -> Selenium e o Unit
Tries to find element and throws an error if it succeeds.
#childExact Source
childExact :: forall o e. Element -> Locator -> Selenium e o Element
Tries to find child, if has no success throws an error
#startSpying Source
startSpying :: forall o e. Selenium e o Unit
#stopSpying Source
stopSpying :: forall o e. Selenium e o Unit
#getWindowHandle Source
getWindowHandle :: forall o e. Selenium e o WindowHandle
#getAllWindowHandles Source
getAllWindowHandles :: forall o e. Selenium e o (List WindowHandle)
#closeWindow Source
closeWindow :: forall o e. Selenium e o Unit