# @wdio/chrome-recorder

> Generate WebdriverIO Tests from Google Chrome DevTools Recordings.

Latest version **0.6.0** (published 2024-04-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @wdio/chrome-recorder
pnpm add @wdio/chrome-recorder
yarn add @wdio/chrome-recorder
bun add @wdio/chrome-recorder
```

Provides the command `chrome-recorder`.

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.6.0 |
| Published | 2024-04-18 |
| First published | 2022-08-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 6 |
| Unpacked size | 31.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 44 |
| Author | Christian Bromann |
| Maintainers | christian-bromann, wdio-user, wswebcreation-nl |
| Keywords | webdriverio, wdio, testing, e2e, automation, devtools |

## Links

- npm: https://www.npmjs.com/package/@wdio/chrome-recorder
- Repository: https://github.com/webdriverio/chrome-recorder
- Homepage: https://github.com/webdriverio/chrome-recorder#readme
- Issues: https://github.com/webdriverio/chrome-recorder/issues
- npm.io page: https://npm.io/package/@wdio/chrome-recorder

## Dependencies (6)

- [meow](https://npm.io/package/meow.md) ^13.2.0
- [chalk](https://npm.io/package/chalk.md) ^5.3.0
- [globby](https://npm.io/package/globby.md) ^14.0.1
- [inquirer](https://npm.io/package/inquirer.md) ^9.2.19
- [prettier](https://npm.io/package/prettier.md) ^3.2.5
- [@puppeteer/replay](https://npm.io/package/@puppeteer/replay.md) ^3.0.0

## Alternatives

- [@snazzah/davey](https://npm.io/package/@snazzah/davey.md) — 1.5M weekly downloads
- [@vendure/testing](https://npm.io/package/@vendure/testing.md) — 8.3K weekly downloads
- [vue-simple-context-menu](https://npm.io/package/vue-simple-context-menu.md) — 6.6K weekly downloads
- [cypress-webpack-preprocessor-v5](https://npm.io/package/cypress-webpack-preprocessor-v5.md) — 2.1K weekly downloads
- [@backstage/plugin-catalog-backend-module-puppetdb](https://npm.io/package/@backstage/plugin-catalog-backend-module-puppetdb.md) — 1.3K weekly downloads

## Recent versions

- 0.6.0 (latest) — 2024-04-18
- 0.1.0-alpha.0 (next) — 2022-08-18
- 0.5.2 — 2023-05-22
- 0.5.1 — 2023-05-22
- 0.5.0 — 2022-11-11
- 0.4.0 — 2022-09-05
- 0.3.4 — 2022-08-24
- 0.3.3 — 2022-08-24
- 0.3.2 — 2022-08-24
- 0.3.1 — 2022-08-24
- 0.3.0 — 2022-08-23
- 0.2.1 — 2022-08-23
- 0.2.0 — 2022-08-22
- 0.1.2 — 2022-08-19
- 0.1.1 — 2022-08-19
- … 1 more at https://npm.io/package/@wdio/chrome-recorder/versions

## README

WebdriverIO Chrome Recorder [![Build](https://github.com/webdriverio/chrome-recorder/actions/workflows/test.yml/badge.svg)](https://github.com/webdriverio/chrome-recorder/actions/workflows/build.yml)
[![npm][npm-badge]][npm]
===========================

This repo provide tools to convert JSON user flows from [Google Chrome DevTools Recorder](https://goo.gle/devtools-recorder) to WebdriverIO test scripts programmatically (WebdriverIO `v7.24.0` or higher required).

✅ Converts multiple recordings to WebdriverIO tests in one go (out-of-the-box glob support)  
🗂 User can pass their custom path to export tests.  
💃 Users can also use a dry run to see the interim output of the recordings  
👨‍💻 Programmatic API which users can use in their own project to create plugins or custom scripts.

Alternatively, you can export JSON user flows as WebdriverIO test scripts straight away from Chrome DevTools with our [WebdriverIO Recorder Chrome extension](https://chrome.google.com/webstore/detail/webdriverio-chrome-record/pllimkccefnbmghgcikpjkmmcadeddfn). 

## 🏗 Installation

```sh
npm install -g @wdio/chrome-recorder
```

## 🚀 Usage

To quickly run the interactive CLI, run:

```sh
npx @wdio/chrome-recorder
```

> The CLI will prompt you to enter the path of directory or file of the chrome devtool recordings that you will modify and path to write the generated WebdriverIO tests

**⚡️ Transform individual recordings**

```sh
npx @wdio/chrome-recorder <path to the chrome devtools recording>
```

**⚡️ Transform multiple recordings**

```sh
npx @wdio/chrome-recorder <path to the chrome devtools recording>*.json
```

👉 By default output will be written to `webdriverio` folder. If you don't have these folders, tool will create it for you or install WebdriverIO by running `npm init webdriverio` in your project.

You can specify different output directory, specify that via CLI:

```sh
npx @wdio/chrome-recorder <path to the chrome devtools recording> --output=<folder-name>
```

## ⚙️ CLI Options

| Option       | Description                                            |
| ------------ | ------------------------------------------------------ |
| -d, --dry    | Dry run the output of the transformed recordings       |
| -o, --output | Output location of the files generated by the exporter |

## 💻 Programmatic API

```javascript
import { stringifyChromeRecording } from '@wdio/chrome-recorder';

const recordingContent = {
  title: 'recording',
  steps: [
    {
      type: 'setViewport',
      width: 1905,
      height: 223,
      deviceScaleFactor: 1,
      isMobile: false,
      hasTouch: false,
      isLandscape: false,
    },
  ],
};

const stringifiedContent = await stringifyChromeRecording(
  JSON.stringify(recordingContent),
);

console.log(stringifiedContent);
// Console Log output
//
// describe('recording', function () {
//   it('tests recording', function (browser) {
//     browser.setWindowRect({ width: 1905, height: 223 });
//   });
// });
```

## 🐛 Issues

Issues with this schematic can filed [here](https://github.com/webdriverio/chrome-recorder/issues)

If you want to contribute (or have contributed in the past), feel free to add yourself to the list of contributors in the package.json before you open a PR!

## 👨‍💻 Development

### Getting started

🛠️ [Node.js and npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) are required for the scripts. Make sure it's installed on your machine.

⬇️ **Install** the dependencies for the WebdriverIO chrome recorder tool

```bash
npm install
```

👷‍♂️ **Build** the tools using typescript compiler

```bash
npm run build
```

🏃 **Run** the tool

```bash
./bin/wdio-chrome-recorder.js
```

### 🧪 Unit Testing

Run the unit tests using mocha as a runner and test framework

```bash
npm run test
```

### ♻️ Clean build files

```bash
npm run clean
```

## Supported Chrome Devtools Recorder Steps

WebdriverIO supports all existing [StepTypes](https://github.com/puppeteer/replay/blob/bcee5b54d94ae3fa1398c41d9166892da617eaad/docs/api/enums/Schema.StepType.md). If any step type seems to be missing, please raise an issue so we can add it. Thanks!

[npm-badge]: https://img.shields.io/npm/v/@wdio/chrome-recorder.svg
[npm]: https://www.npmjs.com/package/@wdio/chrome-recorder

---

For more information on WebdriverIO see the [homepage](https://webdriver.io). The initial implementation was inspired by [Nightwatch Chrome Recorder](https://github.com/nightwatchjs/nightwatch-chrome-recorder)

---
_Source: https://npm.io/package/@wdio/chrome-recorder · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
