- This is WIP: some things weren't implemented, some might have bugs. Filling issues and prs are welcomed!
The main purpose of this library is to provide purescript webdriver/json-wire protocol bindings, such that won't involve any JavaScript dependencies.
- There is a module that encodes any possible error returned by Selenium.
- Low-level API uses
purescript-argonaut'sJsontype andpurescript-affjaxs helper functions (get,postetc) - Endpoints are constructed using
[email protected]type. This module also provides helper functions returningAff (Either Error Json) - Types of requests and resposes live in
Lunapark.Typesmodule. - High-level API uses
purescript-run. There are several functors, but the main two are:LunaparkFandActionF. This functor embed inRunencode almost all posible interactions with w3c/selenium server. - At first
ActionFfunctor (that is a functor that encodes all posible actions like click, hover) is interpreted toLunaparkF, thenLunaparkFis interpreted intoRunwithEXCEPTandAFF|EFFeffects. Lunaparkis facade library on top of api, functors and error.- Capabilities are represented via gradually typed datastructure
Array Capability.initfunction takes a record{ alwaysMatch: Array Capability, firstMatch: Array (Array Capability) }.firstMatchmust have at least on array. - To construct interpreter you need call
[email protected]. The result would beAff (Either Error Interpreter), whereInterpreteris function takingLunaparkmonad and unwrapping it intoRunwithEXCEPTandAFF|EFF. E.g.
main = launchAff do
interpreterOrError ← init "http://localhost:4444/wd/hub" { alwaysMatch: [], firstMatch: [[BrowserName Chrome]] }
case intepreterOrError of
Left err → throwError $ error "An error during selenium session initialization occured"
Right interpret → Run.runBaseAff' $ Run.runExcept $ interpret do
go "http://my-site.com"
el ← findElement $ ByCss $ CSS.fromString ".my-class"
clickEl el
login ← findElement $ ByCss $ CSS.fromString "#login"
password ← findElement $ ByCss $ CSS.fromString "#password"
moveTo { origin: login, x: 0, y: 0, duration: Milliseconds 1000.0 }
click
sendKeys "login"
moveTo { origin: password, x: 0, y: 0, duration: Milliseconds 100.0 }
sendKeys "secret"
sendKeys "\\xE007"- The interpreter takes care about implemented and non-implemented features of particular driver. E.g. if driver supports
GET@/session/:sessionId/timeoutsvia W3C standard it will use it otherwise the interpreter makes it a chain call of JsonWire commands. The same works for actions: they are interpreted into eitherPOST@/session/:sessionId/actionor chains of JsonWire commands.