not really known
Go to file
2024-10-10 08:39:28 +07:00
.github/workflows feat: migrate to spago@next 2024-10-10 08:35:46 +07:00
src purs-tidy format-in-place src/**/*.purs test/**/*.purs 2024-10-10 08:35:47 +07:00
test/Test feat: migrate to spago@next 2024-10-10 08:35:46 +07:00
.gitignore Update for GH actions, PS 0.14 2021-06-14 14:32:06 +01:00
LICENSE prepare release 2018-04-23 17:09:38 +03:00
README.md feat: migrate to spago@next 2024-10-10 08:35:46 +07:00
spago.lock feat: migrate to spago@next 2024-10-10 08:35:46 +07:00
spago.yaml feat: publish 2024-10-10 08:39:28 +07:00

purescript-lunapark

Latest release Build Status

Disclaimer

Webdriver/JsonWire bindings for PureScript

  • This is WIP: some things weren't implemented, some might have bugs. Filling issues and prs are welcomed!

Purescript W3C webdriver protocol bindings

The main purpose of this library is to provide purescript webdriver/json-wire protocol bindings, such that won't involve any JavaScript dependencies.

Architecture

  • There is a module that encodes any possible error returned by Selenium.
  • Low-level API uses purescript-argonaut's Json type and purescript-affjaxs helper functions (get, post etc)
  • Endpoints are constructed using Endpoint@Lunapark.Endpoint type. This module also provides helper functions returning Aff (Either Error Json)
  • Types of requests and resposes live in Lunapark.Types module.
  • High-level API uses purescript-run. There are several functors, but the main two are: LunaparkF and ActionF. This functor embed in Run encode almost all posible interactions with w3c/selenium server.
  • At first ActionF functor (that is a functor that encodes all posible actions like click, hover) is interpreted to LunaparkF, then LunaparkF is interpreted into Run with EXCEPT and AFF|EFF effects.
  • Lunapark is facade library on top of api, functors and error.
  • Capabilities are represented via gradually typed datastructure Array Capability. init function takes a record { alwaysMatch: Array Capability, firstMatch: Array (Array Capability) }. firstMatch must have at least on array.
  • To construct interpreter you need call init@Lunapark.API. The result would be Aff (Either Error Interpreter), where Interpreter is function taking Lunapark monad and unwrapping it into Run with EXCEPT and AFF|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/timeouts via 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 either POST@/session/:sessionId/action or chains of JsonWire commands.