# selenoid-video-api

> Node library to manually control the selenoid video recorder

Latest version **1.3.1** (published 2018-06-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install selenoid-video-api
pnpm add selenoid-video-api
yarn add selenoid-video-api
bun add selenoid-video-api
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.1 |
| Published | 2018-06-20 |
| First published | 2018-06-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 104.2 KB |
| Known vulnerabilities | 0 (+25 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 15 |
| Author | Johan Hernefeldt |
| Maintainers | presidenten |

## Links

- npm: https://www.npmjs.com/package/selenoid-video-api
- Repository: https://github.com/presidenten/selenoid-video-api
- Homepage: https://github.com/presidenten/selenoid-video-api#readme
- Issues: https://github.com/presidenten/selenoid-video-api/issues
- npm.io page: https://npm.io/package/selenoid-video-api

## Dependencies (5)

- [ip](https://npm.io/package/ip.md) ^1.1.5
- [axios](https://npm.io/package/axios.md) ^0.18.0
- [sleep](https://npm.io/package/sleep.md) ^5.1.1
- [fs-extra](https://npm.io/package/fs-extra.md) ^6.0.1
- [wdio-allure-reporter](https://npm.io/package/wdio-allure-reporter.md) ^0.6.2

## Recent versions

- 1.3.1 (latest) — 2018-06-20
- 1.3.0 — 2018-06-19
- 1.2.2 — 2018-06-19
- 1.2.1 — 2018-06-05
- 1.2.0 — 2018-06-04
- 1.1.3 — 2018-06-04
- 1.1.2 — 2018-06-03
- 1.1.1 — 2018-06-03
- 1.1.0 — 2018-06-02
- 1.0.3 — 2018-06-01
- 1.0.2 — 2018-06-01
- 1.0.1 — 2018-06-01
- 1.0.0 — 2018-06-01

## README

# selenoid-video-api
Node library to manually control a custom Selenoid video recorder

## Intro
This library contains a node api to a interact with a custom Selenoid video recorder,
as well as methods that easily plugs into a few Webdriver.io test hooks for easy setup.

This makes it possible to run many test suites in one go and still make separate recordings of each test case.

There is also easy integration with Allure reports to make them pretty:

![Allure example](https://presidenten.github.io/allure-example-report-with-video/assets/allure_example.gif)

Explore the allure example here: [allure-example-report-with-video](https://presidenten.github.io/allure-example-report-with-video)


## Prerequisites
1. Install Node >= v8: [How to install node](https://nodejs.org/en/download/package-manager/)
2. Install Docker: [How to install docker](https://docs.docker.com/install/)
3. Pull the [manual video recorder docker image](https://hub.docker.com/r/presidenten/selenoid-manual-video-recorder/)
  ```shell
      docker image pull presidenten/selenoid-manual-video-recorder
  ```
4. Install [cm](https://github.com/aerokube/cm) for [Selenoid](https://github.com/aerokube/selenoid):
  ```shell
    curl -s https://aerokube.com/cm/bash | bash
  ```
  - Start selenoid with custom manual video recorder
  ```shell
    cm selenoid start --vnc --tmpfs 128 --args "-video-recorder-image presidenten/selenoid-manual-video-recorder"
  ```
- Make a Webdriver.io project [How to get started with Webdriver.io](http://webdriver.io/guide/getstarted/install.html)

## Test the demo
- To run the demo, make sure prerequisites 1-4 are in place, then:
```shell
  git clone https://github.com/presidenten/selenoid-video-api.git
  cd selenoid-video-api

  # Install project dependencies
  npm install

  # Install demo dependencies
  cd demo
  npm install
```
- Run tests
```shell
  npm run test --silent
```
- Generate allure report (optional):
```shell
  npm run allure
```
  Then navigate to from http://localhost:8080/index.html, click on a failing test and check `Execution Video` in test body

- Videos are moved to the output dir and the report dir as report attachments
The library assumes that the selenoid config dir is default (~/.aerokube)
```shell
 ~/github/selenium-video-api/demo/e2e/results$ ls
  User-list-should-be-able-to-move-slider-chrome-2018-06-03--10-29.mp4
  User-list-should-be-able-to-move-slider-chrome-2018-06-03--10-29.png
  User-list-should-be-able-to-multi-select-in-dropdown-chrome-2018-06-03--10-29.mp4
  User-list-should-be-able-to-multi-select-in-dropdown-chrome-2018-06-03--10-29.png
```

## Installation
- Add this module to your test repo
  ```shell
  npm install selenoid-video-api
  ```

- Check the example config to see how to use this module: [wdio.conf.js](https://github.com/presidenten/selenoid-video-api/blob/master/demo/wdio.conf.js)

  (Ofcourse `const selenoidVideoApi = require('../index.js');` from row 1 in the example needs to be changed to: `const selenoidVideoApi = require('selenium-video-api');`)

  - If you want awesome Allure reports, also check `Custom settings` section on how to configure the Allure reporter and make sure to install it as well
    ```shell
      npm install wdio-allure-reporter
    ```

## Configuration

`selenoidVideoApi.getWdioHooks` accepts the following config, with these defaults:

```javascript
  getWdioHooks({
    usingAllure = false,
    saveAllVideos = false,
    waitForVNCTime = 2000,
    videoMinTime = 500,
  })
```

## Working with the video interface separately

tbd


## Under the hood

Normally when using linking docker containers, a one way connection is specified with
environment variables set in one machine so it can reach the other.

To be able to start/stop the recorder, we need a way to trigger the recorder from the browser.
But it is linked to the recorder for vnc, so the browser has no knowledge of the recorder container.

This is my solution:
- Have a middle man (this library) read `env` from each video recorder and make a map of the recorders name, ip and its corresponding browser ip
- Have each spawned browser figure out its ip inside selenium during runtime
- Have an api to trigger commands in the recorder containers, which accepts browser ip to decide which container to run commands in

### For more details:
- Docker integrations:
[video.js](https://github.com/presidenten/selenoid-video-api/blob/master/lib/video.js)

- Webdriver.io integration:
[wdio.conf.js](https://github.com/presidenten/selenoid-video-api/blob/master/demo/wdio.conf.js)

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