# fp-ts-webdriver

> [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

Latest version **4.0.0** (published 2021-02-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install fp-ts-webdriver
pnpm add fp-ts-webdriver
yarn add fp-ts-webdriver
bun add fp-ts-webdriver
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2021-02-26 |
| First published | 2021-02-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 80.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Maintainers | waynevanson |

## Links

- npm: https://www.npmjs.com/package/fp-ts-webdriver
- Repository: https://github.com/waynevanson/fp-ts-webdriver
- Homepage: https://waynevanson.github.io/fp-ts-webdriver
- Issues: https://github.com/waynevanson/fp-ts-webdriver/issues
- npm.io page: https://npm.io/package/fp-ts-webdriver

## Dependencies (2)

- [fp-fetch](https://npm.io/package/fp-fetch.md) ^0.1.1
- [cross-fetch](https://npm.io/package/cross-fetch.md) ^3.0.6

## Recent versions

- 4.0.0 (latest) — 2021-02-26
- 4.0.0-next.3 (next) — 2021-02-26
- 4.0.0-next.2 — 2021-02-21
- 4.0.0-next.1 — 2021-02-21
- 3.1.1 — 2021-02-20
- 3.1.1-next.1 — 2021-02-20
- 3.1.0 — 2021-02-20
- 3.0.0 — 2021-02-18
- 2.0.0 — 2021-02-17
- 1.5.0 — 2021-02-16
- 1.4.0 — 2021-02-16
- 1.3.0 — 2021-02-16
- 1.2.0 — 2021-02-16
- 1.1.0 — 2021-02-14
- 1.0.0 — 2021-02-14
- … 2 more at https://npm.io/package/fp-ts-webdriver/versions

## README

# fp-ts-webdriver

[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

W3C Webdriver API, optimized for usage with fp-ts.

The goal is to be compatible with the [W3C Recommendation](https://www.w3.org/TR/webdriver1)

A webdriver sends requests and returns responses.
We send a request to a driver (chromdriver, geckodriver), it opens up an instance of the browser and runs our requests in real time.

## Installation

Please keep in mind that this is package is experiemental and not enough tests have been written.

```sh
# yarn
## peer dependencies
yarn add fp-ts fp-ts-std io-ts monocle-ts newtype-ts
yarn add fp-ts-webdriver@next

# npm
# peer dependencies
npm install fp-ts fp-ts-std io-ts monocle-ts newtype-ts
npm install fp-ts-webdriver@next
```

## Usage

### Exports

There is currently one named export `webdriver` that exports a namespace of all API's related to the basic webdriver protocol.

When more are added, they'll be available under `chrome`, `firefox` and `edge` respectively.
These will be separated so we can have better intellicense and troubleshooting.

### Example

For this examples to function, you have to turn on your webdriver.
With chromedriver the command is `chromedriver --port=4444`

```ts

import { webdriver as WD, readerReaderTaskEither as RRTE } from "fp-ts-webdriver"
import { pipe } from "fp-ts/lib/function"
import { readerTaskEither as RTE, taskEither as TE } from "fp-ts"

const searchBar = WD.findElement("css selector", "input[name=\"q\"]")
const searchButton = WD.findElement("css selector", "input[value=\"Google Search\"]")

const program = pipe(
  WD.navigateTo("https://google.com.au"),
  RRTE.chain(() => searchBar),
  RRTE.chainFirst((element) => WD.sendKeys("dogs")(element)),
  RRTE.chain(() => searchButton)
  RRTE.chain(element => WD.elementClick(element))
)

export const capabilities: WD.Capabilities = {}

const dependencies:WD.Dependencies =  {
  url: "localhost:4444",
}

// creates a session and closes it after runnning `program`
const main = pipe(
  program, WD.runSession(capabilities)
)

// TE.TaskEither<WD.Errors, void>
main(dependencies)()
```

## Compatibility

We have tests in chromedriver and will expand to other drivers like geckodriver when the time comes.

### Need Something Now?

We're adding features as WE need them in our other projects.

If you would like something in particular, just ask!
We're not taking donations at this stage.

### Table

| Category            | :o:                | Command                 |
| :------------------ | ------------------ | :---------------------- |
| Session             | :heavy_check_mark: | newSession              |
|                     | :heavy_check_mark: | deleteSession           |
|                     | :heavy_check_mark: | status                  |
|                     | :heavy_check_mark: | getTimeouts             |
|                     | :heavy_check_mark: | setTimeouts             |
| Navigation          | :heavy_check_mark: | navigateTo              |
|                     | :heavy_check_mark: | getCurrentUrl           |
|                     | :heavy_check_mark: | back                    |
|                     | :heavy_check_mark: | forward                 |
|                     | :heavy_check_mark: | refresh                 |
|                     | :heavy_check_mark: | getTitle                |
| Command Contexts    | :o:                | getWindowHandle         |
|                     | :o:                | closeWindow             |
|                     | :o:                | switchToWindow          |
|                     | :o:                | getWindowHandles        |
|                     | :o:                | switchtoFrame           |
|                     | :o:                | switchToParentFrame     |
|                     | :o:                | getWindowRect           |
|                     | :o:                | setWindowRect           |
|                     | :o:                | maximizeWindow          |
|                     | :o:                | minimizeWindow          |
| Element Retrieval   | :heavy_check_mark: | findElement             |
|                     | :o:                | findElements            |
|                     | :o:                | findElementFromElement  |
|                     | :o:                | findElementsFromElement |
| Element State       | :o:                | isElementSelected       |
|                     | :heavy_check_mark: | getElementAttribute     |
|                     | :o:                | getElementProperty      |
|                     | :o:                | getElementCSSValue      |
|                     | :o:                | getElementText          |
|                     | :o:                | getElementTagName       |
|                     | :o:                | getElementRect          |
|                     | :o:                | isElementEnabled        |
| Element Interaction | :o:                | elementClick            |
|                     | :o:                | elementClear            |
|                     | :heavy_check_mark: | elementSendKeys         |
| Document Handling   | :o:                | getPageSource           |
|                     | :o:                | executeScript           |
|                     | :o:                | executeAsyncScript      |
| Cookies             | :o:                | getAllCookies           |
|                     | :o:                | getNamedCookie          |
|                     | :o:                | addCookie               |
|                     | :o:                | deleteCookie            |
|                     | :o:                | deleteAllCookies        |
| Actions             | :heavy_check_mark: | performActions          |
|                     | :heavy_check_mark: | releaseActions          |
| User Prompts        | :o:                | dismissAlert            |
|                     | :o:                | acceptAlert             |
|                     | :o:                | getAlertText            |
|                     | :o:                | sendAlertText           |
| Screen Capture      | :o:                | takeScreenshot          |
|                     | :o:                | takeElementScreenshot   |

## Contributing

- Fork and clone this repository `gh repo fork waynevanson/fp-ts-webdriver --clone --remote`
- Install dependencies with `yarn install`
- Ensure tests run in your environment with `yarn test`
  - if chromedriver does not exist, run `yarn add -D chromedriver` to run it's install script, where it will install chromedriver on your machine.
- Commiting
  - Add a feature
  - Add tests
  - Change the compatibility section of `readme.md` under the feature name from `:o:` to `:heavy_check_mark:`
  - Commit message should be of `<fix|feat|docs|build|tests>: <message>`, which is used to generate a changelog.
- Pushing
  - After all commits have been applied, rebase from the master repo with `git pull --rebase`.
  - Push with `git push`

---
_Source: https://npm.io/package/fp-ts-webdriver · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
