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

#getDriver Source

getDriver :: forall o e. Selenium e o Driver

get driver from context

#getWindow Source

getWindow :: forall o e. Selenium e o Window

#getWindowPosition Source

#getWindowSize Source

getWindowSize :: forall o e. Selenium e o Size

#maximizeWindow Source

maximizeWindow :: forall o e. Selenium e o Unit

#setWindowPosition Source

setWindowPosition :: forall o e. Location -> Selenium e o Unit

#setWindowSize Source

setWindowSize :: forall o e. Size -> Selenium e o Unit

#getWindowScroll Source

getWindowScroll :: forall o e. Selenium e o Location

#apathize Source

apathize :: forall a o e. Selenium e o a -> Selenium e o Unit

#attempt Source

attempt :: forall a o e. Selenium e o a -> Selenium e o (Either Error a)

#later Source

later :: forall a o e d. Duration d => d -> Selenium e o a -> Selenium e o a

#get Source

get :: forall o e. String -> Selenium e o Unit

#wait Source

wait :: forall o e d. Duration d => Selenium e o Boolean -> d -> Selenium e o Unit

#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

#byCss Source

byCss :: forall o e. String -> Selenium e o Locator

#byXPath Source

byXPath :: forall o e. String -> Selenium e o Locator

#byId Source

byId :: forall o e. String -> Selenium e o Locator

#byName Source

byName :: forall o e. String -> Selenium e o Locator

#byClassName Source

byClassName :: forall o e. String -> Selenium e o Locator

#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

#findElements Source

findElements :: forall o e. Locator -> Selenium e o (List Element)

#findChild Source

findChild :: forall o e. Element -> Locator -> Selenium e o (Maybe Element)

Tries to find child and return it wrapped in Just

#findChildren Source

findChildren :: forall o e. Element -> Locator -> Selenium e o (List Element)

#getInnerHtml Source

getInnerHtml :: forall o e. Element -> Selenium e o String

#getSize Source

getSize :: forall o e. Element -> Selenium e o Size

#getLocation Source

getLocation :: forall o e. Element -> Selenium e o Location

#isDisplayed Source

isDisplayed :: forall o e. Element -> Selenium e o Boolean

#isEnabled Source

isEnabled :: forall o e. Element -> Selenium e o Boolean

#getCssValue Source

getCssValue :: forall o e. Element -> String -> Selenium e o String

#getAttribute Source

getAttribute :: forall o e. Element -> String -> Selenium e o (Maybe String)

#getText Source

getText :: forall o e. Element -> Selenium e o String

#clearEl Source

clearEl :: forall o e. Element -> Selenium e o Unit

#clickEl Source

clickEl :: forall o e. Element -> Selenium e o Unit

#sendKeysEl Source

sendKeysEl :: forall o e. String -> Element -> Selenium e o Unit

#script Source

script :: forall o e. String -> Selenium e o Foreign

#getCurrentUrl Source

getCurrentUrl :: forall o e. Selenium e o String

#navigateBack Source

navigateBack :: forall o e. Selenium e o Unit

#navigateForward Source

navigateForward :: forall o e. Selenium e o Unit

#navigateTo Source

navigateTo :: forall o e. String -> Selenium e o Unit

#setFileDetector Source

#getTitle Source

getTitle :: forall o e. Selenium e o String

#sequence Source

sequence :: forall o e. Sequence Unit -> Selenium e o Unit

Run sequence of actions

#actions Source

actions :: forall o e. ({ defaultTimeout :: Milliseconds, driver :: Driver | o } -> Sequence Unit) -> Selenium e o Unit

Same as sequence but takes function of ReaderT as an argument

#stop Source

stop :: forall o e. Selenium e o Unit

Stop computations

#refresh Source

refresh :: forall o e. Selenium e o Unit

#quit Source

quit :: forall o e. Selenium e o Unit

#takeScreenshot Source

takeScreenshot :: forall o e. Selenium e o String

#saveScreenshot Source

saveScreenshot :: forall o e. String -> Selenium e o Unit

#findExact Source

findExact :: forall o e. Locator -> Selenium e o Element

Tries to find element, if has no success throws an error

#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

#clearLog Source

clearLog :: forall o e. Selenium e o Unit

#getXHRStats Source

getXHRStats :: forall o e. Selenium e o (List XHRStats)

#getWindowHandle Source

#getAllWindowHandles Source

#switchTo Source

switchTo :: forall o e. WindowHandle -> Selenium e o Unit

#closeWindow Source

closeWindow :: forall o e. Selenium e o Unit